Please give me a hand with my problem. I would like to set 3 different profit targets for the trades and when each target is reached the stop loss should rise to the level of the previous target (or any other value that was previously set ).
For 1 profit target and 1 stop loss moved to the specified level, I used the code that I partially posted below.
Please tell me how can I do this with 2 more targets?
Thank you advance!
protected override void Initialize() { SetStopLoss(CalculationMode.Ticks, stoplossticks); SetProfitTarget(CalculationMode.Ticks, profittargetticks); CalculateOnBarClose = true; } protected override void OnBarUpdate() { if (Position.MarketPosition == MarketPosition.Flat) { SetStopLoss(CalculationMode.Ticks, stoplossticks); } else if (Position.MarketPosition == MarketPosition.Long) { if (Close[0] > Position.AvgPrice + 50 * TickSize) { SetStopLoss(CalculationMode.Price, Position.AvgPrice + 30 * TickSize); } }
Comment