I have inserted in my strategy the following code, to set the stoploss to breakeven for a long and a short position:
// Condition set 3
if (Position.MarketPosition == MarketPosition.Long
&& GetCurrentBid() >= Position.AvgPrice + Breakeven_Long * TickSize)
{
SetStopLoss("", CalculationMode.Price, Position.AvgPrice + 2* TickSize, true);
}
// Condition set 4
if (Position.MarketPosition == MarketPosition.Short
&& GetCurrentBid() <= Position.AvgPrice + Breakeven_Short * TickSize)
{
SetStopLoss("", CalculationMode.Price, Position.AvgPrice - 2* TickSize, true);
}
// Condition set 5
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, Stop_Loss);
}
Breakeven_Short and Breakeven_Long are user defined inputs.
Breakeven_Short is a negative number, so I expect it to be subtracted to the position.avgprice.
Now, when I run the strategy on historical data, nothing happens.
What could be missing?
thank you,
John.

Comment