Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding Second Timeframe to Indicator

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

    Adding Second Timeframe to Indicator

    Hello,

    I've developed a custom indicator that works well in the 1 minute chart, but to make it perfect I need a confirmation from another indicator in the 5 minute chart.
    Any pointer on how to incorporate a value from another timeframe into NinjaScript would be much appreciated.

    Thanks in advance.

    #2
    Hello laocoon,

    Thanks for your post.

    If I understand correctly you want to add a 5-minute data series to your indicator.

    To do so you would need to use AddDataSeries() or its variations (depends on bar type), please see this link: https://ninjatrader.com/support/help...dataseries.htm in the examples on that page is one that shows adding a 5-minute bar.

    Once you have added the data series you will need to change your coding to work with a Multi Time frame and we recommend reviewing the help guide here (a large section but important): https://ninjatrader.com/support/help...nstruments.htm

    Basics to consider that both data series will call the OnBarUpdate() (OBU) method and this will change the references unless you specifically code otherwise. As an example, if your code uses Close[0], when the 1-minute series calls OBU, it will return the close price of the current 1-minute bar, when the 5-minute series calls OBU Close[0] would then be of the 5-minute bar. The referenced help guide section will help clarify how you can refer to both series (IE: Closes[0][0] would be the current close price of the 1-minute series and Closes[1][0] would be the current close price of the 5-minute series).

    If you need to add an indicator to your indicator and you want the indicator to reference the higher time frame then you would initialize the added indicator with the added data series, for example:

    In State.Configure you would have:

    AddDataSeries(BarsPeriodType.Minute, 5);

    In State.DataLoaded, you could have

    myEMAHTF = EMA(Closes[1], 15); // myEMAHTF will be a 15 period EMA using the 5 minute price series close price

    (Note: at the class level you would also have private EMA myEMAHTF)

    In the OnBarUpdate() when you want the value of the 5 minute 15 period EMA you would use

    if (myEMAHTF[0] > Highs[0][0])
    {
    // do something
    }


    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    579 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 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
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X