It uses both historical and real time processing. I am not sure but when there is no signal prints indicate orders gets opened and closed i am not sure where its coming from. Is it from historical processing? if I include this then I dont get similar ghost orders in print statements.
if (State != State.Realtime) //Only trades realtime. Ignores historical trades.
{
return;
}
my entry and Print methods
if(BullBearFlag)
{
if (State == State.Historical && CurrentBar == BarsArray[0].Count - 2)
{
if (entryOrderFS != null)
{
suppressOcoF = true;
exitNameF = "exit to start flat";
exitFlatF = placeHolderOrderF;
ExitShort(0, 1, exitNameF, entryOrderFS.Name);
}
}
else if(beforeTradeShortCheck && bearFlagEntry && Close[0] > bearFlagEntryLevel && entryOrderFS == null
&& profitTargetFS == null && stopLossFS == null && GetCurrentAsk() >= bearFlagEntryLevel && !exitOnCloseWaitF)
{
// EnterShort(0,PositionSize, "LB Short");
suppressOcoF = false;
entryOrderFS = placeHolderOrderF;
EnterShortStopMarket(0,true, PositionSize, bearFlagEntryLevel,"Flag Short");
bearFlagEntry = false;
}
if(entryOrderFS != null && IsFirstTickOfBar && stochPrim[0] < maxStochFlagShort && stochPrim[0] > minStochFlagShort && bearFlagEntry && Close[0] > bearFlagEntryLevel
&& riskBearFlag < riskFlag && GetCurrentAsk() >= bearFlagEntryLevel && trendDirection == -1 && isLowSequence)
{
EnterShortStopMarket(0,true, PositionSize, bearFlagEntryLevel,"Flag Short");
Print("entryOrderFS Reentry"+entryOrderFS);
}
if(entryOrderFS != null )
{
Print("entryOrderFS check:" + entryOrderFS);
}
if(entryOrderFS != null && IsFirstTickOfBar && (stochPrim[0] >= maxStochFlagShort || riskBearFlag > riskFlag || !isLowSequence ))
{
CancelOrder(entryOrderFS);
Print("Cancel Sell order" + Time[0]);
}
if (ordersCancelledFS)
{
Print("stop and/or target cancelled or rejected");
// if the orders were cancelled due to the exit on close, do not submit an order to flatten
if (!exitOnCloseWaitF && entryOrderFS != null && entryOrderFS.OrderState == OrderState.Filled)
{
Print("exiting and resetting");
exitNameF = "exit for cancel";
exitFlatF = placeHolderOrder;
ExitShort(exitNameF, entryOrderFS.Name);
}
if (entryOrderFS == null || entryOrderFS.OrderState != OrderState.Filled)
Print(" entry not filled or is null");
ordersCancelledFS = false;
return;
}
}
my prints
Enabling NinjaScript strategy 'LineBreakerAlgoTest/312671954' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=Unique entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes
entryOrderFS checkrderId='NT-00186-5147' account='Sim101' name='Flag Short' orderState=Cancelled instrument='NQ 12-24' orderAction=SellShort orderType='Stop Market' limitPrice=0 stopPrice=20189.25 quantity=3 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-09-24 12:18:30' gtd='2099-12-01' statementDate='2024-09-24'
Cancel Sell order9/24/2024 2:46:00 PM
entryOrderFS checkrderId='NT-00186-5147' account='Sim101' name='Flag Short' orderState=Cancelled instrument='NQ 12-24' orderAction=SellShort orderType='Stop Market' limitPrice=0 stopPrice=20189.25 quantity=3 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-09-24 12:18:30' gtd='2099-12-01' statementDate='2024-09-24'
Cancel Sell order9/24/2024 2:46:30 PM
entryOrderFS checkrderId='NT-00186-5147' account='Sim101' name='Flag Short' orderState=Cancelled instrument='NQ 12-24' orderAction=SellShort orderType='Stop Market' limitPrice=0 stopPrice=20189.25 quantity=3 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-09-24 12:18:30' gtd='2099-12-01' statementDate='2024-09-24'
Cancel Sell order9/24/2024 2:47:00 PM
entryOrderFS checkrderId='NT-00186-5147' account='Sim101' name='Flag Short' orderState=Cancelled instrument='NQ 12-24' orderAction=SellShort orderType='Stop Market' limitPrice=0 stopPrice=20189.25 quantity=3 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-09-24 12:18:30' gtd='2099-12-01' statementDate='2024-09-24'
Cancel Sell order9/24/2024 2:47:30 PM

rderId='4c104f088036465bafdf219478e54c72' account='Playback101' name='Flag Long' orderState=Cancelled instrument='NQ 12-24' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=20082.5 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=211341 time='2024-09-23 10:06:01' gtd='2099-12-01' statementDate='2024-09-23'
Comment