Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Chart Variable

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

    Chart Variable

    Is there way to have a variable that can be accessed/shared among the indicators on a chart?

    Scenario:
    I have several indicators where I specify a look back period. Currently this is set for each indicator. I was looking for a way to set the value in one place so all the indicators on that chart (not other charts) could access/read the variable/value.

    #2
    Originally posted by ct View Post
    Is there way to have a variable that can be accessed/shared among the indicators on a chart?

    Scenario:
    I have several indicators where I specify a look back period. Currently this is set for each indicator. I was looking for a way to set the value in one place so all the indicators on that chart (not other charts) could access/read the variable/value.
    That depends on what you mean, and your programming abilities.

    Here is one method that you might use:
    1. Create a (master) indicator that publicly exposes the period that you want to set.
      Make sure that you give this indicator a specific name, using this.Name = ... in the Initialize() section, so that you can search on this name.
    2. In your other indicators, cycle through the indicators list, and if the indicator is loaded, then read the variable and set the lookBack period from it, otherwise do nothing.
    3. Load the master indicator onto the chart, along with the other indicators.

    Comment


      #3
      Hello ct,

      Thank you for your post.

      Along with koganam's suggestion you could use a UserDefinedMethod to send the period from one indicator to be used in all indicators. However, there are foreseeable conflicts with multiple indicators trying to set the period and resulting in undesired results.

      UserDefinedMethods: http://www.ninjatrader.com/support/h...ed_methods.htm

      Comment


        #4
        Originally posted by NinjaTrader_PatrickH View Post
        Hello ct,

        Thank you for your post.

        Along with koganam's suggestion you could use a UserDefinedMethod to send the period from one indicator to be used in all indicators. However, there are foreseeable conflicts with multiple indicators trying to set the period and resulting in undesired results.

        UserDefinedMethods: http://www.ninjatrader.com/support/h...ed_methods.htm
        Not unless the variable is declared static, which of course brings along with it, inter alia, the concerns that you have already expressed. It is often best practice to avoid using static variables.

        Comment

        Latest Posts

        Collapse

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