Hi, I am developing a strategy that works in barclose. with a fixed stop it works perfectly, but I want to implement a break even, which is activated at X ticks in favor without the need for the candle to close. my code, as i say, is onbarupdate () ... barclose, and then i apply break even with this code:
protected override void OnMarketData(MarketDataEventArgs marketDataUpdate) { // Print some data to the Output window if (marketDataUpdate.MarketDataType == MarketDataType.Last) { if ((Position.MarketPosition == MarketPosition.Long) && (marketDataUpdate.Price >= (Position.AveragePrice + (100 * TickSize)))) { SetStopLoss("L1", CalculationMode.Price, Position.AveragePrice+ (4 * TickSize), false); } } if (marketDataUpdate.MarketDataType == MarketDataType.Last) { if ((Position.MarketPosition == MarketPosition.Short) && (marketDataUpdate.Price <= (Position.AveragePrice - (100 * TickSize)))) { SetStopLoss("S1", CalculationMode.Price, Position.AveragePrice- (4 * TickSize), false); } } }
Do you see any mistake?
Comment