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

When to use addDataSeries vs SessionIterator (& vice versa) - PriorDayOHLC as example

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

    When to use addDataSeries vs SessionIterator (& vice versa) - PriorDayOHLC as example

    So, I've been developing with NT8 for a few months now, slowly building my understanding of NT, but I've kind of hit a wall regarding a couple fundamental questions of how to handle multiple timeframes:

    Recently, I started out by using addDataSeries to add the daily timeframe to my indicator (which uses 60-minute bars for the primary data series). This led to a situation where the 'daily' price data I was working with always ended one hourly-bar too early. After some research I understood that I must need to bring in a SessionIterator to fix this issue, but it was then that I realized that in NT's default PriorDayOHLC script multi-timeframes are achieved without any addDataSeries calls at all, and just done solely with SessionIterator!

    So at this point I wondering if multi-timeframes can done without addDataSeries - then why ever use addDataSeries at all? (my guess is that there ARE cases where one cannot get by with merely SessionIterator to achieve their multi-timeframe goals, but I'm at a complete loss to know which situation those are. Ultimately, I'm betting that I'm fairly 'turned-around/confused')

    If someone with more knowledge of addDataSeries vs SessionIterator could spill some of it here and set me right it would be very much appreciated. (particularly in regard to when to use one vs the other, and/or if SessionIterator always has to accompany an addDataSeries call)
    Last edited by Calebg; 02-13-2019, 01:47 PM.

    #2
    Hello Calebg,

    Thanks for your post.

    The answer is it depends on what you are trying to do.

    In the case of PriorDayOHLC, it is an intraday based indicator that uses the session trading hours to say here is when the session begins and ends. It should not be considered a multi-time frame as all it does is provide prior session levels using the same data as you are charting. So this would work if you are using RTH or ETH based sessions and were looking for price levels based on that data.

    The "Pivots" (or any of the pivots indicators) may pull in daily bars based on " if (priorDayHlc == HLCCalculationMode.DailyBars) AddDataSeries(BarsPeriodType.Day, 1);" which then creates it as a multi time frame. In this case, Daily bars are used to provide the previous days OHLC values to a set of calculations for pivot levels. The reason this would be different is that the Close value of daily bars can be the contracts settlement price, (depending on data feed) which would be different than the intraday data's last price of the session. Daily bars are also ETH only regardless of trading hours session applied to intraday data.

    An example for MultiTimeFrames use would be the use of a moving average built on a different period, for example, a 10 period EMA based on 15 minute bars. A MACD based on 30 minute data.

    It is easy to get turned around in Multi Time Frame especially considering that historically you are looking back at the last previously closed bar whereas in real time data, if you are using Calculate.OnEachTick or Calculate.OnPriceChange your references would be to the currently forming bar. The help guide actually does a pretty good job of laying all this out and it takes a few reads to absorb all the info but this is the best reference for MTF: https://ninjatrader.com/support/help...nstruments.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the thoughtful reply.

      I think a lot of confusion for me probably is coming from the implications of the "How Bars Data is Referenced" section of the "Multi-Time Frame & Instruments" handbook page, so maybe a better/specific question would be - when does a SessionIterator need to be used in conjunction with addDataSeries?

      SessionIterators, clearly don't seem to be required every time an addDataSeries is used in a script (based on examples I've seen), but I have a feeling that the lack of a SessionIterator is what made the daily addDataSeries OHLC values not line up correctly with my 1-hour bars correctly...

      Comment


        #4
        Hello Calebg,

        Thanks for your reply.

        As previously mentioned Daily bars, in NT8, are fixed to an ETH session and no application of trading hours (trading session) can change the Daily bars view. The trading hours can impact intraday data such as your 60-minute bars.

        The definition of the sessioniterator is: Allows you to traverse through various trading hours data elements which apply to a segment of bars. The elements are listed on the session iterator help guide page: https://ninjatrader.com/support/help...oniterator.htm

        I suspect the issue you described in your first post may not be related to sessioninterator so much as understanding how the bar data is referenced historically. When your code is run on historical data it will be run as if Calculate.OnBarClose is true meaning that in any time frame the bar index of [0] is pointing to the last closed bar. In the help guide section on multi time frame titled, "How Bars Data is Referenced", the first diagram shown is described as, "Figure 1 below demonstrates the concept of bar processing on historical data or in real-time when the Calculate property is set to Calculate.OnBarClose." would be applicable.

        As a suggestion, you may want to verify your data/results by using Print statements in your script(s) to provide information such as BarsInProgress and either bar numbers and/or bar closing times and bar values to help sort out what is being accessed and when and see if that matches up with the historical bar expectations as defined in the help guide. Here is a link to our debugging tips: https://ninjatrader.com/support/help...script_cod.htm

        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by kaywai, 09-01-2023, 08:44 PM
        5 responses
        601 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        6 responses
        22 views
        0 likes
        Last Post xiinteractive  
        Started by Pattontje, Yesterday, 02:10 PM
        2 responses
        18 views
        0 likes
        Last Post Pattontje  
        Started by flybuzz, 04-21-2024, 04:07 PM
        17 responses
        230 views
        0 likes
        Last Post TradingLoss  
        Started by agclub, 04-21-2024, 08:57 PM
        3 responses
        17 views
        0 likes
        Last Post TradingLoss  
        Working...
        X