Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Persistent variables

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

    Persistent variables

    Hello,

    Is it possible to set persistent variables that can be stored and re-used?

    Example:

    On the first 5-min bar, I would like to set a variable bSomeValue = 1. And on the last 5-bar I would like to re-use that bSomeValue variable again.

    Is this possible? Or are all variables lost after each completed bar?

    #2
    Hi siroki,

    If the variables are declared in the #region Variables region then the variables will be persistent through each call to OnBarUpdate and will only be set when you set them.

    If you are declaring the variables in OnBarUpdate, then these will be re-created and thus reset on every call to OnBarUpdate.

    So really it depends on where you are declaring the variable.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for answering this question. Yes! Ofcourse! Why didn't I think of using the variables!

      Oh, have I told you guys how much Ninjatrader and especially the support team rocks?

      You guys rock! #happycamper

      Comment

      Latest Posts

      Collapse

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