Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

barsago offset not working for positive numbers

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

    barsago offset not working for positive numbers

    Hello all. I'm brand new to NinjaScript, but I am an experienced programmer. However, this is thoroughly confusing me and I think I must simply be ignorant of some idiosyncrasy of the language.

    While trying to code a new indicator, I'm not able to reference any past bars in my scripting. Whenever I use a positive value for the 'barsago' offset index variable, I get blank indicator values. Not undefined, just blank. Even if I simplify my entire indicator down to:
    Plot0.Set(Close[1]); I still get nothing. Plot0.Set(Close[0]); works fine and plots the current close, and Plot0.Set(Close[-1]); works as well and plots the next close. But I simply cannot reference past bars with a positive 'barsago' value.

    Please help.

    #2
    You are not referencing the past before it exists, such as on bar 0 are you?

    Does your OnBarUpdate() begin with something like

    Code:
     if (CurrentBar < [enough bars so you won't end up negative]) return
    --EV

    Comment


      #3
      jdcm.admn, please try ETFVoyageur's idea and let us know if that solves the issue. There is a reference tip detailing this behavior here.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Thank you both for your help. That solved my issue.

        Now, is there any way I can tell the software to alert me when exceptions are thrown? That would have probably helped me solve things initially.

        Comment


          #5
          Just have a look at the log tab of the Control Center, you would see the exception you ran into listed there.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          579 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X