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:	224
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 jclose, Today, 09:37 PM
        0 responses
        5 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,414 views
        0 likes
        Last Post Traderontheroad  
        Started by firefoxforum12, Today, 08:53 PM
        0 responses
        11 views
        0 likes
        Last Post firefoxforum12  
        Started by stafe, Today, 08:34 PM
        0 responses
        11 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by sastrades, 01-31-2024, 10:19 PM
        11 responses
        169 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X