The code compiles, and executes but the execution I get when running this code is essentially at the entry price. I think that means that my calculation of maxprofit0 is incorrect or the subsequent calculation of the actual profit target (profit0) is off. Can you give me any advice on what to fix in the example code below?
Thanks
DaveN
protected override void OnBarUpdate() { if (CurrentBars[0] < DP_Period || CurrentBars[0] < V_Period) return; double maxhigh0 = MAX(High, MM_Period)[0]; double minlow0 = MIN(Low, MM_Period)[0]; double maxprofit0 = (int)(maxhigh0 - minlow0); double profit0 = Instrument.MasterInstrument.RoundToTickSize(maxprofit0 * Profit_Factor); if(Position.MarketPosition == MarketPosition.Long && BarsSinceEntryExecution() <= 2) { SetProfitTarget(@"BSDV_L", CalculationMode.Price, (Position.AveragePrice + profit0)); } else if(Position.MarketPosition == MarketPosition.Short && BarsSinceEntryExecution() <= 2) { SetProfitTarget(@"BSDV_S", CalculationMode.Price, (Position.AveragePrice - profit0)); }
Comment