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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      388 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      260 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      218 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      301 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      268 views
      0 likes
      Last Post CarlTrading  
      Working...
      X