Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 samish18, 04-17-2024, 08:57 AM
          16 responses
          55 views
          0 likes
          Last Post samish18  
          Started by arvidvanstaey, Today, 02:19 PM
          3 responses
          9 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          8 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          18 views
          0 likes
          Last Post traderqz  
          Started by algospoke, 04-17-2024, 06:40 PM
          5 responses
          47 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X