I have a bit of a problem with my strategy and cannot figure out why. Even though I set the strategy rule EntriesPerDirection=1, on LIVE testing sometimes it opens 2 positions and I don't understand why. During the back tests everything seems fine but on live testing every now and then it open 2 positions. Here below is my code, maybe the execution order is wrong, any suggestion to improve the code would be appreciated.
if (Close[0] <= sell_price)
{
if (Position.MarketPosition == MarketPosition.Long)
{
ExitLong(0, 1, "reversing","buy");
EnterShort(0, 1, "sell");
}
if (Position.MarketPosition == MarketPosition.Flat)
{
EnterShort(0, 1, "sell");
}
}

Comment