Dear community and NT team,
I am building a strategy that uses an indicator that is updated OnEachTick.
The logic is simple to enter:
if condition 1 then limit long
if condition 2 then limit short
else then cancel limit long and short
However, i am unable to cancel the orders the limit orders. Once one of the limit orders is created i can't cancel in the same bar if the indicator say to not enter..
I am trying with CancelOrder but i might be missing something... Can someone help?
For reference, adding the piece of the code that i am working currently:
if (Position.MarketPosition == MarketPosition.Flat)
{
if (Close[0] >= HHH1 - 5
&& ProjectedVolume < SMA(Volume, 10)[0]
)
{
entryOrder = EnterShortLimit(2, HHH1 + EntryFactorS, @"MMDS1");
//EnterShortLimit(2, HHH1 + EntryFactorS, "MMDS1");
}
else if (Close[0] <= LLL1 + 5
&& ProjectedVolume < SMA(Volume, 10)[0]
)
{
entryOrder = EnterLongLimit(2, LLL1 - EntryFactorL, @"MMDL1");
//EnterLongLimit(2, LLL1 - EntryFactorL, "MMDL1");
Print("enter order");
}
else
{
CancelOrder(entryOrder);
Print("need to cancel working orders");
}
}

Comment