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

Strategy Stop Working after a while

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

    Strategy Stop Working after a while

    [IMG]file:///C:/Users/Sohail/AppData/Local/Temp/msohtmlclip1/01/clip_image001.png[/IMG][IMG]file:///C:/Users/Sohail/AppData/Local/Temp/msohtmlclip1/01/clip_image002.png[/IMG]I apologize for my ignorance. I am new to ninjatrader and trying to understand the strategy builder. I have created a very basic strategy where bar cross below the upper bar of Keltner channel then strategy enters short. Profit target is 10 pips and there is no stop loss. When I enabled strategy in market replay environment then strategy starts working very smoothly but after a while, it stops making short entries when condition met. Entry per direction is set to 10. Start behavior is set to immediately submit. I have tried other start behavior as well but the results are the same. The strategy also checks before entering into a trade that last entered trade was at-least 10 bars ago. Please refer attached1 where condition met but the strategy did not enter short:[IMG]file:///C:/Users/Sohail/AppData/Local/Temp/msohtmlclip1/01/clip_image004.png[/IMG]
    Please refer marked area in attached1.

    Please refer attached2 which shows the strategy position and account position.

    Thanks for help in advance.
    [IMG]file:///C:/Users/Sohail/AppData/Local/Temp/msohtmlclip1/01/clip_image006.png[/IMG]
    Attached Files

    #2
    Hello sohailashra,

    Are you hitting the limit of 10 entries in the same direction?

    What is the position when the orders stop?

    If you enable TraceOrders, do you see any messages appearing in the NinjaScript Output Window that orders are being ignored?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea B.

      Thanks for your reply. Limit of 10 is not reach. u can see in attached2 that position is 3000 (each trade is for 1000 units). Therefore there are 3 open trades in short direction which is less than 10.

      My understanding is that limit on direction trade means that strategy will keep trading until there are 10 open trades. After reaching the limit strategy will stop making trades until atleast 1 trade is closed and then strategy will start trading till open trades equals to 10 again. please correct my understanding if I am woring.

      For trace I can check it again but as far as I remember there was no message of order being ignored.

      Thanks,

      Comment


        #4
        Hello sohailashraf,

        Where you have mentioned:
        "My understanding is that limit on direction trade means that strategy will keep trading until there are 10 open trades"

        I want to clarify that these orders are based on the position. If you were to place 100 working orders all at the same time, this would be allowed. If 10 orders have filled and contributed to the open position, a new 11th order placed after this would be ignored.

        Below is a link to the help guide with a description.
        https://ninjatrader.com/support/help...rdirection.htm

        I was not able to confirm, is TraceOrders enabled?
        Do you see the orders are ignored or that this order was submitted with the traceorders in the output window? (You will see a message for one or the other if the condition to submit the order has evaluated as true)

        May I see the output so that I may see the time the condition is true and the trace orders information?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Please refer attached screenshot. Are you referring to this output. I do not see any order submitted message or order ignored message for that particular bar.

          If attached screen shot is not you are referring then please guide me where to get this trace.

          Thanks for your help in advance.
          Attached Files

          Comment


            #6
            Hello sohailashraf,

            TraceOrders and prints which are used to debug a script and understand behavior go to the NinjaScript Output Window.

            New > NinjaScript Output

            Below is a link to a forum post that discusses using Prints and TraceOrders to understand behavior.
            https://ninjatrader.com/support/foru...121#post791121

            Please enable TraceOrders and include the full output from the NinjaScript Output window. (Right-click the window > select Save As)
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Chelsea B.

              Thanks for your response. I enabled the trace and i found ignored submit order. However I am not able to understand that how it exceeded entry signal since I have put number of trade per direction as 10 and short position is just 3000.

              Per trade quantity is 1000. So if you divide 3000 by 1000 then trade per direction comes to 3.

              Following is the trace log.

              4/15/2019 9:17:46 PM Strategy 'zV1KCSell/89516685': Entered internal SubmitOrderManaged() method at 4/15/2019 9:17:46 PM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1,000 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              4/15/2019 9:17:46 PM Strategy 'zV1KCSell/89516685': Ignored SubmitOrderManaged() method at 4/15/2019 9:17:46 PM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1,000 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'


              Regards,

              Comment


                #8
                Hello sohailashraf,

                From the output you are getting ignored orders because it is exceeding the entries per direction. This is why the strategy stops trading.

                4/15/2019 9:17:46 PM Strategy 'zV1KCSell/89516685': Ignored SubmitOrderManaged() method at 4/15/2019 9:17:46 PM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1,000 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

                Either increase the EntriesPerDirection, or reduce the number of trades that can be placed in a direction and contribute to the position.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello sohailashraf,

                  From the output you are getting ignored orders because it is exceeding the entries per direction. This is why the strategy stops trading.

                  4/15/2019 9:17:46 PM Strategy 'zV1KCSell/89516685': Ignored SubmitOrderManaged() method at 4/15/2019 9:17:46 PM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1,000 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

                  Either increase the EntriesPerDirection, or reduce the number of trades that can be placed in a direction and contribute to the position.
                  Hi Chelsea,

                  I have a similar issue with a strategy. It suddenly stops working and closes itself. I noticed there was the "ignored submit order" message, so I changed the entry conditions, such that the message does not appear anymore. Will that solve the issue? Would there be any other reason that may cause the "going dormant" issue that you know of?

                  BobPerez
                  Last edited by bobperez; 03-25-2024, 07:28 AM.

                  Comment


                    #10
                    Hello BobPerez,

                    The output from sohailashraf is showing the script is not going dormant but is already in a position and exceeding the entries per direction, so the position would need to be exited first, or more entries allowed.

                    For your script, this would depend on why the order is being ignored, which will be stated in the output message.

                    If you changed the logic to prevent all entries, no entries would be placed.
                    If the script was ignored orders due to exceeding the entries per direction, exiting the position or allowing more entries in a direction would allow for new entries.

                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello BobPerez,

                      The output from sohailashraf is showing the script is not going dormant but is already in a position and exceeding the entries per direction, so the position would need to be exited first, or more entries allowed.

                      For your script, this would depend on why the order is being ignored, which will be stated in the output message.

                      If you changed the logic to prevent all entries, no entries would be placed.
                      If the script was ignored orders due to exceeding the entries per direction, exiting the position or allowing more entries in a direction would allow for new entries.
                      Thank you Chelsea,
                      In my case, a buy order may be ignored because there was a live sell order submitted, and vice-versa. What I did, is I cancelled the sell order before submitting the new buy order...and so forth.

                      Comment


                        #12
                        Hello bobperez,

                        Yes, submitting working orders while there are orders in the opposite direction will be ignored.

                        Below is a link to the help guide on the order handling rules.
                        NinjaScript > Language Reference > Strategy > Order Methods > Managed Approach​ > Internal Order Handling Rules that Reduce Unwanted Positions

                        Cancelling the opposing order first would work.

                        You could also use the unmanaged approach if you wanted to have both orders working. (Note, you would want to have logic to prevent both orders from being able to fill)
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Ok, thank you Chelsea.

                          BobPerez

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by RookieTrader, Today, 09:37 AM
                          3 responses
                          14 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by kulwinder73, Today, 10:31 AM
                          0 responses
                          5 views
                          0 likes
                          Last Post kulwinder73  
                          Started by terofs, Yesterday, 04:18 PM
                          1 response
                          23 views
                          0 likes
                          Last Post terofs
                          by terofs
                           
                          Started by CommonWhale, Today, 09:55 AM
                          1 response
                          3 views
                          0 likes
                          Last Post NinjaTrader_Erick  
                          Started by Gerik, Today, 09:40 AM
                          2 responses
                          7 views
                          0 likes
                          Last Post Gerik
                          by Gerik
                           
                          Working...
                          X