Scenario 1: when the time is decided to change and the order didn't hit the target exit position AND set a new limit order the opposite direction;
Scenario 2: if the order wasn't filled Cancel the order AND set a new limit order the opposite direction.
What I am finding out it can cancel the order but skips setting up the reversal order. I think the code doesn't think it is flat.
if (Position.MarketPosition == MarketPosition.Short)
{
if (nTarget1Contracts != 0)
ExitShort("Short1");
if (nTarget2Contracts != 0)
ExitShort("Short2");
if (nTarget3Contracts != 0)
ExitShort("Short3");
}
else
{
if (oEntryOrder1 != null)
{
oEntryOrder1 = GetRealtimeOrder(oEntryOrder1);
CancelOrder(oEntryOrder1);
}
if (oEntryOrder2 != null)
{
oEntryOrder2 = GetRealtimeOrder(oEntryOrder2);
CancelOrder(oEntryOrder2);
}
if (oEntryOrder3 != null)
{
oEntryOrder3 = GetRealtimeOrder(oEntryOrder3);
CancelOrder(oEntryOrder3);
}
}
if (Position.MarketPosition == MarketPosition.Flat)
{
{
if (nTarget1Contracts != 0 && bTradeEnabled == true)
{
SetProfitTarget("Long1", CalculationMode.Price, dPrice1, true);
SetStopLoss("Long1", CalculationMode.Price, dPrice2, false);
if (bUseMar****rder == true)
EnterLong(nTarget1Contracts, "Long1");
else
EnterLongLimit(0, true, nTarget1Contracts, dPrice3, "Long1");
}
}
Comment