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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      67 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      36 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      59 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      62 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Working...
      X