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:	275
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 NullPointStrategies, Today, 05:17 AM
        0 responses
        38 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        64 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X