Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

order sometimes not created

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    order sometimes not created

    Hi,

    I have a mutli time frame and multi instrument strategy. The primary data series is 5minute ES. The secondary data series is 1 tick MES and the third data series is 1tick ES. The order on MES created based on bar close execution from 5min ES data series.

    Each 5min at bar close, it will issue an EnterLongLimit() on the secondary data series (1 tick MES data series). It will check whether there is an existing order. If there is an existing order, it will first cancel the existing order and then create the new order.

    The problem is sometimes, it won't create the new order after the order cancellation. It happens intermittently. How can I fix this issue?

    #2
    Hello affilife,

    Thank you for your post.

    I recommend debugging using prints to see how the conditions are evaluating and enabling TraceOrders. TraceOrders specifically will tell us if the order is being ignored, cancelled, submitted etc.

    Below is a link to a forum post that demonstrates using prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.


    Enable TraceOrders, print the time of the bar and all values used in the conditions that submit entry orders. Include labels for all values and comparison operators.

    Let me know if you need any assistance creating a print or enabling TraceOrders.

    Save the output from the output window to a text file and provide this with your reply.

    I'll be happy to assist with analyzing the output.​
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      I spent a lot of times debugging using Print method. The code executed successfully. There was no order ignored. So I am hoping you can help write a best practices sample code where the order is created on a 1 tick secondary data series once the primary data series is executed on bar close. And if there is an existing order, cancel it before creating that new order

      Comment


        #4
        I added a condition to check order cancel to make sure orderstate is cancelled before adding a new order. This works now. Looks like there is a race condition between cancel order and adding new order. When cancel order still trying to cancel and a new order already submited, it fails to add new order. This happens intermittently as i mentioned .

        Comment


          #5
          Hello affilife,

          Thank you for your response.

          I added a condition to check order cancel to make sure orderstate is cancelled before adding a new order.
          I think this was a good course of action. This will ensure the order is definitely cancelled before attempting to submit a new order.

          When cancel order still trying to cancel and a new order already submited, it fails to add new order.
          Can you clarify, is the new order being submitted or not? Since your condition checks if the order state is cancelled before adding the new order, if the cancellation is pending it will not evaluate as true.

          I look forward to your response.
          Gaby V.NinjaTrader Customer Service

          Comment


            #6
            It works now with the checking condition. If I don't have the checking condition, it will sometimes not submit the new order.

            Comment


              #7
              I am having the same problem where the output says the order is submitted but no order actually gets submitted...


              3/11/2024 7:52:15 PM Strategy 'aaaWR_LONG_dual_202401/321302988': Entered internal SetStopTarget() method: Type=TrailStop FromEntrySignal='R_PB' Mode=Ticks Value=60 IsSimulatedStop=True IsMarketIfTouched=False

              Print statement: ------------ enter long order submitted. ----------------

              3/11/2024 7:52:15 PM Strategy 'aaaWR_LONG_dual_202401/321302988': Entered internal SubmitOrderManaged() method at 3/11/2024 7:52:15 PM: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=5 LimitPrice=18299.75 StopPrice=0 SignalName='R_PB' FromEntrySignal=''

              Print statement: Long limit price: 18299.625
              Print statement:= = = Qty: 0
              Print statement:= = = Avg: 0

              3/11/2024 7:52:15 PM Strategy 'aaaWR_LONG_dual_202401/321302988': Amended trail stop order orderId='65ec43b37b384caab44e82e10088afbc' account='APEX-32064-66' name='Trail stop' orderState=TriggerPending instrument='MNQ 03-24' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=18039 quantity=3 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=3768 time='2024-03-11 19:52:15' gtd='2099-12-01' statementDate='2024-03-11' stopPriceChanged=18039.25

              3/11/2024 7:52:26 PM Strategy 'aaaWR_LONG_dual_202401/321302988': Amended trail stop order orderId='65ec43b37b384caab44e82e10088afbc' account='APEX-32064-66' name='Trail stop' orderState=TriggerPending instrument='MNQ 03-24' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=18039.25 quantity=5 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=3768 time='2024-03-11 19:52:15' gtd='2099-12-01' statementDate='2024-03-11' stopPriceChanged=18040.75

              This is the output... why is average fill price 0?
              Also... when it says the order is submitted... no order actually appears. Why is that?

              Comment


                #8
                Hello halgo_boulder,

                Thank you for your post.

                The output is showing an order is being submitted. What order are you referring to when you say "no order actually appears"?

                The average fill price is 0 because the order has not been filled yet.


                Print statement: ------------ enter long order submitted. ----------------

                3/11/2024 7:52:15 PM Strategy 'aaaWR_LONG_dual_202401/321302988': Entered internal SubmitOrderManaged() method at 3/11/2024 7:52:15 PM: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=5 LimitPrice=18299.75 StopPrice=0 SignalName='R_PB' FromEntrySignal=''​
                Gaby V.NinjaTrader Customer Service

                Comment


                  #9
                  Normally the limit orders appear on the chart.

                  No orders appear.

                  During market replay (testing) they appear.

                  Comment


                    #10
                    Hello halgo_boulder,

                    Thank you for your response.

                    Can you clarify, is the strategy not submitting orders at all? Or are the trade markers not appearing on the chart? Is this for live, or historical orders?
                    Gaby V.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi, the strategy is submitting orders but the trade markers are not appearing on the chart.
                      This is for both market replay and live market.

                      Comment


                        #12
                        Hello halgo_boulder,

                        Do you have the Chart Trader closed? The Chart Trader needs to be open for the open stop and limit order markers to show on the chart.

                        Do you have Plot executions to set 'Do not plot' in the Data Series window? This will prevent the previous executions from being marked on the chart.

                        Please let me know if I can assist further.

                        Gaby V.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by AaronKoRn, Today, 09:49 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post AaronKoRn  
                        Started by carnitron, Today, 08:42 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post carnitron  
                        Started by strategist007, Today, 07:51 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post strategist007  
                        Started by StockTrader88, 03-06-2021, 08:58 AM
                        44 responses
                        3,975 views
                        3 likes
                        Last Post jhudas88  
                        Started by rbeckmann05, Today, 06:48 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post rbeckmann05  
                        Working...
                        X