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

I need to constantly Disable and Enable my strategy to keep it running!

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

    I need to constantly Disable and Enable my strategy to keep it running!

    Hi everyone, I am writing a strategy that checks some conditions and then places an order if we meet those conditions. I am running it live right now (Sim Acct). The strategy stops working after meeting those conditions maybe 3 to 4 times. I have to disable it and able it for the strategy to keep working. Are there settings that do not allow my strategy to keep running? My script seems to be ok.

    #2
    Hello patdmoney,

    Thank you for your post and welcome to the NinjaTrader Forum Community!

    So I may accurately assist you, please answer all of the following questions:
    • When you say that the strategy "stops working" what do you mean? Is it becoming disabled with a message on the Log tab of the Control Center? What color is the strategy name on the Strategies tab of the Control Center when it stops working?
    • Was this strategy created in the Strategy Builder or is it an unlocked strategy in the NinjaScript Editor?
    • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)
    • Who are you connected to? This is displayed in green in the lower-left corner of the Control Center window.
    • Who is your broker?
    • What instrument symbol (and expiry if applicable) have you selected? For example, ES 03-22, AAPL, EURUSD, etc.
    • What interval is selected? For example, 5 minute, 1 day, 2000 volume, 4 Renko, etc.
    • Do you receive an error on the screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?
    I look forward to your reply.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Hi Emily,
      • When you say that the strategy "stops working" what do you mean? Is it becoming disabled with a message on the Log tab of the Control Center? What color is the strategy name on the Strategies tab of the Control Center when it stops working?
      It behaves like it is disabled but I don't have any message on the Log tab and it is green when stops working.
      • Was this strategy created in the Strategy Builder or is it an unlocked strategy in the NinjaScript Editor?
      I created it via the NinjaScript Editor.
      • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)
      The version number 8.1.2.0 64-bit
      • Who are you connected to? This is displayed in green in the lower-left corner of the Control Center window.
      NinjaTrader
      • Who is your broker?
      NinjaTrader
      • What instrument symbol (and expiry if applicable) have you selected? For example, ES 03-22, AAPL, EURUSD, etc.
      ES 12-23
      • What interval is selected? For example, 5 minute, 1 day, 2000 volume, 4 Renko, etc.
      1 minute
      • Do you receive an error on the screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?
      No Errors whatsoever

      Comment


        #4
        Hello patdmoney,

        Thank you for your reply.

        Since there are no error messages and the strategy name still shows in green, that means the strategy is still enabled and set up to submit orders if the proper conditions are met. To debug your strategy and understand why it is not behaving as expected, I suggest enabling TraceOrders to get output related to when orders are submitted, ignored, changed, or canceled:

        This can be enabled by setting TraceOrders to true in State.SetDefaults.

        Another helpful tool for debugging your strategy's behavior is adding print statements throughout your logic. For more information on using prints to debug:


        If you do not understand the output from TraceOrders and/or your prints, please right-click the NinjaScript Output window and select Save As to save the output to a text file. Then, attach the text file with your response so we can take a look and assist you further.

        Please feel free to reach out with any additional questions or concerns.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Hi, I have enabled the TraceOrders and I got nothing. The strategy works exactly like I want even though it seems to detect the event only three times then I need to disable and enable it like a reset. I was wondering if that was my script that limited me to those 3. It’s kind of kill the purpose of running a script.

          Comment


            #6
            Hello patdmoney,

            Thank you for your reply.

            Please try adding prints, such as a print inside of the condition where the event is detected as well as a general print in OnBarUpdate(). Review the NinjaScript Output window, especially after the three times the event has already been detected, to see which additional prints are generated. If you see only the print from OnBarUpdate() and not the print inside of your condition, that means that the condition is not being triggered again at that point. Printing the values used in the condition can help you understand why it might not be triggered again after the first three times. This would shed some light on what the cause of the unexpected behavior is and what needs to be modified in your logic to get the desired behavior. Something in your script may be limiting you to those 3 events, and prints will help you to determine if that is the case or not and why.

            Thank you for your patience.
            Emily C.NinjaTrader Customer Service

            Comment


              #7
              I got it working thanks

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by samish18, Today, 03:53 AM
              0 responses
              1 view
              0 likes
              Last Post samish18  
              Started by binzel, Today, 03:18 AM
              0 responses
              1 view
              0 likes
              Last Post binzel
              by binzel
               
              Started by stalt, 12-28-2015, 01:36 PM
              8 responses
              1,569 views
              0 likes
              Last Post Víitnnhatrangdotvn  
              Started by Rocksworx, Today, 02:29 AM
              0 responses
              5 views
              0 likes
              Last Post Rocksworx  
              Started by lcgamarra_pinnacle, 06-15-2024, 09:33 AM
              2 responses
              33 views
              0 likes
              Last Post AlexMocc  
              Working...
              X