Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get indicator values ​​from another chart

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

    Get indicator values ​​from another chart

    Hi, if i have 2 charts from same instrument for example one with candles of 5 minute an another with candles of 1 minutes, and i add a indicator to the 5 minute chart, it is possible if i add a strategy to the 1 minute chart to get values or variables from indicator in 5 minute chart?

    #2
    Hello arbeydario,

    Thanks for your post.

    You would need to add an additional data series to your script using AddDataSeries() for the instrument/timeframe you want to get the indicator value from. If an instrument is not specified, the primary instrument will be used. For example, you could add a 5-minute data series to your script by calling AddDataSeries(BarsPeriodType.Minute, 5); in the State.Configure section of OnStateChange.

    After adding an additional data series, you could pass Closes[1] as the Series<double> input argument for that secondary data series in when instantiating your indicator in State.DataLoaded. You could then print out that indicator value or use it in a condition or action.

    See the sample code below.

    Code:
    //class level variable
    private SMA SMA1;
    
    //OnStateChange
    else if (State == State.Configure)
    {
        AddDataSeries(Data.BarsPeriodType.Minute, 5);
    }
    else if (State == State.DataLoaded)
    {
        SMA1 = SMA(Closes[1], 14);
    }
    
    //OnBarUpdate
    protected override void OnBarUpdate()
    {
        Print("SMA1: " + SMA1[0]);
    }
    See the help guide documentation below for more information and sample code.

    AddDataSeries: https://ninjatrader.com/support/help...dataseries.htm
    Closes: https://ninjatrader.com/support/help...nt8/closes.htm
    SMA: https://ninjatrader.com/support/help...simple_sma.htm
    Working with Multi-Timeframe/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm

    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3

      Thanks Brandon, i will read the documentation

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      43 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      48 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X