I hope you can help me please. I'm trying to code an iceberg order that places an initial long order, waits to monitor the fills, and once filled submits a further long order (rinsing and repeating). My code isn't working as only the first order submits and fills, the second order is not firing (but should, my debug statements before my EnterLong() request are being called). I've tried simplifying the code down to its very basics in an attempt to debug but it's still not working. I'm sharing the basic code below and example print statements. Please could anyone take a look at the code and print statements here and let me know if I'm missing something fundamental? I've run this on Sim101 for ticker AMZN on 10sec bars using Chart and adding Strategy.
Firstly I've attached the code - it does a basic entry if Close is above a moving average. There's no exit logic in here (just trying to enter properly first).
Secondly, here is the print statement when testing this using my Sim101 account. You can see that it fires the initial EnterLong correctly, and this first batch fills. The last two lines are debug statements that surround the EnterLong request within OnExecutionUpdate that should make a second order for qty=100. This implied that the code is being called within OnExecutionUpdate, but for an unknown reason its not firing. When I look at my control center orders tab, it doesn't show any second order of 100 qty.
Enabling NinjaScript strategy 'TestingEnterLongWIthinOnExecutionUpdate/238461547' : On starting a real-time strategy - StartBehavior=WaitUntilFlat AccountPosition=AMZN 600L EntryHandling=All 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 Debug1 Time: 9/8/2022 3:55:50 PM, State: Realtime, Close[0]: 129.57, _emaClose[0]: 129.500466717952 Debug2 Time: 9/8/2022 3:55:50 PM, State: Realtime, Close[0]: 129.57, _emaClose[0]: 129.500466717952 Entry OnOrderUpdate Ticker: AMZN, Time[0]: 9/8/2022 3:55:50 PM, BarsInProgress: 0, Setting entryOrder = order: orderId='27330b53a8ca4846a8b12fe00c666648' account='Sim101' name='BuyLong1' orderState=Submitted instrument='AMZN' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=200 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=1107 time='2022-09-08 15:55:52' gtd='2099-12-01' statementDate='2022-09-08'. Rule: order.Name == BuyLong1 Entry OnOrderUpdate Ticker: AMZN, Time[0]: 9/8/2022 3:55:50 PM, BarsInProgress: 0, Setting entryOrder = order: orderId='27330b53a8ca4846a8b12fe00c666648' account='Sim101' name='BuyLong1' orderState=Accepted instrument='AMZN' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=200 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=1107 time='2022-09-08 15:55:52' gtd='2099-12-01' statementDate='2022-09-08'. Rule: order.Name == BuyLong1 Entry OnOrderUpdate Ticker: AMZN, Time[0]: 9/8/2022 3:55:50 PM, BarsInProgress: 0, Setting entryOrder = order: orderId='27330b53a8ca4846a8b12fe00c666648' account='Sim101' name='BuyLong1' orderState=Working instrument='AMZN' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=200 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=1107 time='2022-09-08 15:55:52' gtd='2099-12-01' statementDate='2022-09-08'. Rule: order.Name == BuyLong1 Entry OnOrderUpdate Ticker: AMZN, Time[0]: 9/8/2022 3:55:50 PM, BarsInProgress: 0, Setting entryOrder = order: orderId='27330b53a8ca4846a8b12fe00c666648' account='Sim101' name='BuyLong1' orderState=Filled instrument='AMZN' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=200 tif=Gtc oco='' filled=200 averageFillPrice=129.58 onBehalfOf='' id=1107 time='2022-09-08 15:55:52' gtd='2099-12-01' statementDate='2022-09-08'. Rule: order.Name == BuyLong1 ENTRY OnExecutionUpdate Ticker: AMZN, execution.Time: 9/8/2022 3:55:52 PM, Time[0]: 9/8/2022 3:55:50 PM, BarsInProgress: 0, CurrentBar: 6994, execution.Order.OrderState: Filled, execution.Order.Filled: 200, sumFilled: 200, entryOrder: orderId='27330b53a8ca4846a8b12fe00c666648' account='Sim101' name='BuyLong1' orderState=Filled instrument='AMZN' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=200 tif=Gtc oco='' filled=200 averageFillPrice=129.58 onBehalfOf='' id=1107 time='2022-09-08 15:55:52' gtd='2099-12-01' statementDate='2022-09-08', execution.OrderId: 27330b53a8ca4846a8b12fe00c666648, execution.Name: BuyLong1, Message: We sum the quantities of each execution making up the entry order. 0. Time: 9/8/2022 3:55:50 PM, buyBatchQty: 200, sumFilled: 200, buyBatchQty == sumFilled: True, execution.Order.OrderState: Filled, 1a. Time: 9/8/2022 3:55:50 PM 1b. Time: 9/8/2022 3:55:50 PM 3. Time: 9/8/2022 3:55:50 PM 5. Time: 9/8/2022 3:55:50 PM 6. Time: 9/8/2022 3:55:50 PM, startBuyingSlot: 2, buyBatchQty: 100, myBuyOrder: BuyLong2, BarsInProgress: 0, latestBuyBar: 6994 7. Time: 9/8/2022 3:55:50 PM, startBuyingSlot: 2, buyBatchQty: 100, myBuyOrder: BuyLong2, BarsInProgress: 0, latestBuyBar: 6994
Many thanks in advance
ChainsawDR

Comment