Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator for multiple time series on the same chart

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

    Indicator for multiple time series on the same chart

    Hello,

    Is it possible to retrieve/calculate the value of an indicator from multiple time series on the same chart?

    Let’s say I have ES 15 and 60 minutes time frames on the same chart. I add SMA to each time series. Can I get the value of 60 SMA within 15 min SMA?

    I am thinking of using the following logic to add time series within indicator, but not sure if this is the best way to achieve my goal;

    Add("ES ##-##", PeriodType.Minute, 60); Then I can refer to price as Close[1][0], but calculation will be tricky since OnBarUpdate will run of 15 min chart.

    Thanks,
    redduke

    #2
    Hi RedDuke,

    Yes, this is possible. It looks like you've gotten started a bit on our multiseries framework.

    This statement adds the 60 minute series.
    Add("ES ##-##", PeriodType.Minute, 60);

    The primary would be 15 minute, or BarsInProgress == 0.
    The secondary is the 60 minute, or BarsInProgress == 1.

    Can I get the value of 60 SMA within 15 min SMA?
    For this, you use BarsInProgress to define the context of updates to the 15 minute series, and then calculate SMA using Closes[1] series as its input.

    Code:
    if (BarsInProgress == 0)
    {
    double mySMA = SMA(Closes[1], 14)[0];
    }
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks a lot. This is exactly what I needed.

      Comment


        #4
        Is there a way to also plot the indicator on the screen? On single time series strategy one can use Add(SMA(Period)) in the Initialize section and that will plot the indicator on the screen.

        However, on a multiple timeseries strategy, the statement Add(BarsArray[1], Period) does not work.

        It does not work because one cannot reference the BarsArray in the initialize section. Also, it is not possible to use the Add statement on any other section other that the initialize section.
        Last edited by cesario; 08-08-2012, 09:01 AM.

        Comment


          #5
          Hi cesario,

          Yes, this is possible. The multi-series items needs to be within a custom indicator, and its plot set on it. The custom indicator will be visualized with multiseries values when you Add() it from strategy.

          In custom indicator MySixtyMinuteSMA Initialize:
          Add(PeriodType.Minute, 60);

          OnBarUpdate()
          Value.Set(SMA(Closes[1], 14)[0]);

          In strategy Initialize()
          Add(MySixtyMinuteSMA());
          Last edited by NinjaTrader_RyanM1; 08-08-2012, 09:39 AM.
          Ryan M.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

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