My custom strategy places the entry order as follows:
EnterBuyLimit(0, true, oi.shares, oi.price, oi.orderID); // oi is an order instruction class price member is double shares member is int
Places the cover after execution as follows:
ExitLongStopMarket(0, true, oi.shares, oi.price, oi.orderID, oi.targetOrderID); // oi member targetOrderID is the orderID of entry order
Ninja Log:
2020-03-27 10:59:17:796|3|4|Strategy 'DoubleTee/196784471': A Sell stop order placed at '3/23/2020 6:01:02 PM' has been ignored since the stop price is greater than or equal to the close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
2020-03-27 10:59:18:769|1|4|Enabling NinjaScript strategy 'DoubleTee/196784471' : On starting a real-time strategy - StartBehavior=WaitUntilFlat Position=NQ 06-20 1S, NQ 06-20 1S EntryHandling=All entries EntriesPerDirection=2 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
2020-03-27 10:59:21:241|1|16|NinjaScript strategy 'DoubleTee/196784471' submitting order
2020-03-27 10:59:21:243|1|32|Order='39e82f70347f481dbfc05b4b5 e9a48bc/Sim101' Name='Limit-5894' New state='Submitted' Instrument='NQ 06-20' Action='Buy' Limit price=7624 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2020-03-27 10:59:21:343|1|32|Order='39e82f70347f481dbfc05b4b5 e9a48bc/Sim101' Name='Limit-5894' New state='Accepted' Instrument='NQ 06-20' Action='Buy' Limit price=7624 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2020-03-27 10:59:21:348|1|32|Order='39e82f70347f481dbfc05b4b5 e9a48bc/Sim101' Name='Limit-5894' New state='Working' Instrument='NQ 06-20' Action='Buy' Limit price=7624 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2020-03-27 10:59:21:349|1|32|Order='39e82f70347f481dbfc05b4b5 e9a48bc/Sim101' Name='Limit-5894' New state='Filled' Instrument='NQ 06-20' Action='Buy' Limit price=7624 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=1 Fill price=7622.75 Error='No error' Native error=''
2020-03-27 10:59:21:351|1|8|Execution='0b7803edcf014b2ca0c4d6 2b504376aa' Instrument='NQ 06-20' Account='Sim101' Exchange=Default Price=7622.75 Quantity=1 Market position=Long Operation=Operation_Add Order='39e82f70347f481dbfc05b4b5e9a48bc' Time='03/27/2020 10:59:21'
2020-03-27 10:59:21:355|1|64|Instrument='NQ 06-20' Account='Sim101' Average price=7622.75 Quantity=1 Market position=Long Operation=Operation_Add
2020-03-27 10:59:58:266|1|32|Order='fd1fe00c407842e08dda0d14b 3f2de99/Sim101' Name='Sell' New state='Submitted' Instrument='NQ 06-20' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2020-03-27 10:59:58:274|1|4|Disabling NinjaScript strategy 'DoubleTee/196784471'
2020-03-27 10:59:58:380|1|32|Order='fd1fe00c407842e08dda0d14b 3f2de99/Sim101' Name='Sell' New state='Accepted' Instrument='NQ 06-20' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2020-03-27 10:59:58:383|1|32|Order='fd1fe00c407842e08dda0d14b 3f2de99/Sim101' Name='Sell' New state='Working' Instrument='NQ 06-20' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2020-03-27 10:59:58:387|1|32|Order='fd1fe00c407842e08dda0d14b 3f2de99/Sim101' Name='Sell' New state='Filled' Instrument='NQ 06-20' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=1 Fill price=7613.75 Error='No error' Native error=''
2020-03-27 10:59:58:389|1|8|Execution='2f63c1d8a77b4e9b899bcd c8ed810ed2' Instrument='NQ 06-20' Account='Sim101' Exchange=Default Price=7613.75 Quantity=1 Market position=Short Operation=Operation_Add Order='fd1fe00c407842e08dda0d14b3f2de99' Time='03/27/2020 10:59:58'
2020-03-27 10:59:58:391|1|64|Instrument='NQ 06-20' Account='Sim101' Average price=0 Quantity=0 Market position=Flat Operation=Remove
My Log:
Enabling NinjaScript strategy 'DoubleTee/196784471' : On starting a real-time strategy - StartBehavior=WaitUntilFlat Position=NQ 06-20 1S, NQ 06-20 1S EntryHandling=All entries EntriesPerDirection=2 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
3/27/2020 10:59:18 AM: Entering Realtime State DoubleTee(DT) @ 3/27/2020 10:59:18 AM
3/27/2020 10:59:18 AM: Running in Wait Until Flat mode
3/27/2020 10:59:18 AM: Canceling all Orders...
3/27/2020 10:59:18 AM: Exiting Positions...
3/27/2020 10:59:21 AM: StartPositionEntry: A1, 1, LONG, EWA.Bar
3/27/2020 10:59:21 AM: New Position Created: DoubleTee_NQ 06-20_Sim101_DT-5893
3/27/2020 10:59:21 AM: Placing BuyLimit @ 7624.00Target: 7627.50 - LimitOrder::StartEntryLogic()
3/27/2020 10:59:21 AM: BuyLimit [email protected] - Limit-5894
3/27/2020 10:59:21 AM: OnOrderUpdate(Limit-5894) Buy/Submitted: Shares: 1@7624
3/27/2020 10:59:21 AM: OnOrderUpdate(Limit-5894) Buy/Accepted: Shares: 1@7624
3/27/2020 10:59:21 AM: OnOrderUpdate(Limit-5894) Buy/Working: Shares: 1@7624
3/27/2020 10:59:21 AM: OnOrderUpdate(Limit-5894) Buy/Filled: Shares: 1@7624
3/27/2020 10:59:21 AM: Starting TrailingStop(128,64,8,False) - TrailingStop::StartExitLogic()
3/27/2020 10:59:21 AM: Target: 7655.75 Ratchet: 8 - TrailingStop::StartEntryLogic()
3/27/2020 10:59:21 AM: Placing SellToCoverStopMarket @ 7607.75 - TrailingStop::StartExitLogic()
3/27/2020 10:59:21 AM: SellToCoverStopMarket [email protected] - TrailingStop-5895 Limit-5894
3/27/2020 10:59:21 AM: Terminating DoubleTee(DT) @ 3/27/2020 10:59:58 AM
3/27/2020 10:59:21 AM: Canceling all Orders...
3/27/2020 10:59:21 AM: Exiting Positions...
3/27/2020 10:59:21 AM: Terminated DoubleTee(DT) @ 3/27/2020 10:59:58 AM
Disabling NinjaScript strategy 'DoubleTee/196784471'
Comment