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 can't keep enabled when applied

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

    Strategy can't keep enabled when applied

    Hi everyone!
    My problem is that i have coded a strategy on ninjascript editor. it is compiled successfully. but when i apply it to the char (I'm connected to datafeed (green)) it can't keep enabled and it doesn't give any result!
    I need your help!

    #2
    Hello KacemRhaz ,

    If the strategy does not stay enabled that would hint at a runtime error. Have you checked the NinjaScript output window or the Control center Log tab after trying to enable it?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you jess, I have checked the control center log i found that the strategy encounters this problem:
      error on calling "onbarupdate" on bar 63, you are accessing an index with a value that is invalid since it is out of range
      as mentionned on the image joined below, i made a variable called "n_pre_low" which means the number of bars to look back in order to determine a lower low condition for an oscillator!

      Click image for larger version

Name:	ninja capture.PNG
Views:	225
Size:	5.1 KB
ID:	1114346

      Comment


        #4
        Hello KacemRhaz,

        Thanks for checking that.

        This is a fairly general error which occurs when you try to use an invalid index. From the picture I don't see anything which would cause this error, this would come from something like an indicator use or an array where you are trying to access an index that does not exist. This can also be generated if you used a BarsAgo too soon, for example using 2 BarsAgo on bar 0 would generate a similar error.

        The error gives some insight, this happened on bar 63 so that can give an idea of what part of the logic would have been having an error. If your n_pre_low was less than 63 we can ignore this part of the logic, it would have gone past that condition at the time of the error.

        You can additionally track this down by adding some prints into your script. For example:

        Print("1");
        // some of your code
        Print("2");
        // more code
        Print("3");
        You would then see a lot of output up until the error where you could see which print it stopped at last, that will give a more accurate location on what line is having an error. Once you track down the line that's having the error if its not apparent what the problem is you could post that part of the code. I could give some suggestions on what to Print there to get a better idea of the situation.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by giulyko00, Yesterday, 12:03 PM
        3 responses
        12 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by habeebft, Today, 07:27 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_ChristopherS  
        Started by AveryFlynn, Today, 04:57 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by Max238, Today, 01:28 AM
        4 responses
        39 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by r68cervera, Today, 05:29 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X