Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to call indicator from indicator

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

    how to call indicator from indicator

    I know have some function like :
    AddChartIndicator called in State == State.DataLoaded

    However, this is only work for using strategy to call indicator.

    What i want is called indicator from indicator.

    #2
    Hello cincai,
    You can do as below:
    1. Before OnStateChange(), private SMA sma1;
    2. In DataLoaded, sma1 = SMA(Period);
    3. In OnBarUpdate(), now you can use as required. Example - Plot1[0] = sma1[0]; // this will plot SMA
    Hope it helps!

    Comment


      #3
      Hello cincai,

      Thanks for your post.

      For indicators, there is not an AddChartIndicator() method. Just to clarify, AddChartIndicator() is a convenience method for the purpose of adding indicators to a chart when a strategy is loaded. The strategy does not have to use the indicator within the strategy (typically they do).

      As forum member s.Kinra advised, in order to see a plot from another indicator, in an indicator, you would have to create a plot for it and assign the indicator value to it. You would create a private instance of the indicator, initialize the indicator in state.DataLoaded and in OnBarUpdate() assign the indicator value to the plot you created.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      80 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X