|
Brisbane, Australia
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus/Zen-Fire
Trading: CL
Posts: 670 since Jun 2009
Thanks Given: 134
Thanks Received: 430
|
Hi everyone
As most of you know I am very active in developing the Hurley strategy that Big Mike initiated.
The latest version of Hurley is working well. It can use up to 5 contracts per trade with each contract having a different profit target. I use an initial setstoploss for all contracts which moves to BE + half the ticks of the first target when the first target is hit. I use a variable "cumprofittarget" to define the total cumulative profit for the strategy for that session (presently $1000) and another variable, cumlosstarget, for a loss target. I use CalculateOnBarClose=true.
Have a look at the latest version: Hurley6_7a_NT or Hurley6_7a_6_5. The profit targets in ticks for Target1, Target2, Target3, Target4, and Target 5 are 20, 20, 20, 20, and 150. Therefore using Big Mikes method the actual profit targets on the CL are 20, 40, 60, 80, and $1500. The reason I like the very big last target is to extend staying in the trade to avoid re-entries with retracements.
However, I want to improve the strategy so that when cumprofittarget is exceeded when one or more contracts are still in play in a trade, the cumprofittarget is protected. For example in a long if cumprofittarget is exceeded by 20 ticks, I could reset the setstoploss to a number of ticks below the current price (eg close of the last bar). The reason for this as frequently the cumprofittarget is exceeded by a large margin after the 3rd contract is hit
This part of my code that exits when the cumulative profit or loss target is hit works OK:
if (Position.MarketPosition != MarketPosition.Flat) return;
/* Prevents further trading if the current session's cumulative profit or loss targets are realised. */
if (Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit >= cumprofittarget || Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit <= -cumlosstarget)
{
return;
}
I am trying to add the code after the above to protect the cumprofittarget and have tried the following but it doesn't appear to work (beyond my current expertise):
if ((Position.MarketPosition == MarketPosition.Long)
&& ((Position.GetProfitLoss(Close[0], PerformanceUnit.Currency)) - cumprofittarget) >= 200)
{
SetStopLoss("target1", CalculationMode.Price, Math.Min(GetCurrentBid(), - (20 * TickSize)), false);
SetStopLoss("target2", CalculationMode.Price, Math.Min(GetCurrentBid(), - (20 * TickSize)), false);
SetStopLoss("target3", CalculationMode.Price, Math.Min(GetCurrentBid(), - (20 * TickSize)), false);
SetStopLoss("target4", CalculationMode.Price, Math.Min(GetCurrentBid(), - (20 * TickSize)), false);
SetStopLoss("target5", CalculationMode.Price, Math.Min(GetCurrentBid(), - (20 * TickSize)), false);
}
if ((Position.MarketPosition == MarketPosition.Short)
&& ((Position.GetProfitLoss(Close[0], PerformanceUnit.Currency)) - cumprofittarget) >= 200)
{
SetStopLoss("target1", CalculationMode.Price, Math.Min(GetCurrentBid(), + (20 * TickSize)), false);
SetStopLoss("target2", CalculationMode.Price, Math.Min(GetCurrentBid(), + (20 * TickSize)), false);
SetStopLoss("target3", CalculationMode.Price, Math.Min(GetCurrentBid(), + (20 * TickSize)), false);
SetStopLoss("target4", CalculationMode.Price, Math.Min(GetCurrentBid(), + (20 * TickSize)), false);
SetStopLoss("target5", CalculationMode.Price, Math.Min(GetCurrentBid(), + (20 * TickSize)), false);
}
Does anyone have any ideas?
Thanks in advance,
Nano
|