Announcement

Collapse
No announcement yet.

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.

    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:	286
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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        147 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        71 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        125 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        79 views
        0 likes
        Last Post PaulMohn  
        Working...
        X