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

AddDataSeries() not respecting its requested tradingHours to calculate Close[0]

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

    AddDataSeries() not respecting its requested tradingHours to calculate Close[0]

    Hello

    I am trying to make an indicator that adds Daily time frame OHLC levels to intraday time frames charts, by using AddDataSeries() to add the Daily time frame DataSeries and and using its
    BarsInProgress == 1 filter in the OnBarUpdate() called Calculate.OnBarClose.

    With the chart trading hours manually set to "Default 24 x 5" in the Data Series properties inspector, and using an AddDataSeries() overload that attempts to also set the trading hours to "Default 24 x 5"... which sets Open and Close trading hours from midnight to midnight:

    AddDataSeries( this.Instrument.FullName, new BarsPeriod{ BarsPeriodType = BarsPeriodType.Day, Value = 1 }, "Default 24 x 5");

    While OnBarUpdate() IS called OnBarClose as expected at midnight for the added daily data series.
    The Open[0] and Close[0] values for added daily data series do not reflect the requested trading hours... the Close[0] returned is from 5pm (or 6pm sorry a little hard to tell on a forex instrument with price stored in float that causes price rounding inaccuracies) and NOT midnight as expected?

    I initially tried using the simpler AddDataSeries() overload, which the API notes say the added data series will use the properties of the primary chart data series:

    AddDataSeries(BarsPeriodType.Day, 1);

    Both seem ignore the chart configured and dynamically requested trading hours when calculating Open[0] and Close[0] ...possibly High[0] and Low[0] also.
    It seems to possibly still be using the "Instrument Default" trading hours to form the OHLC for the the added data series?

    I would like the OHLC for the the added data series to be calculated based on its "bar" opening at midnight and closing midnight. To match the charts primary bars.
    Is there a way to control the Open and Close times of added data series?

    Thanks
    Last edited by SmartArtsStudio; 07-05-2021, 08:17 AM.

    #2
    Hello SmartArtsStudio,

    Thanks for your post.

    Daily bars are not adjustable by the trading hours. Daily bars are ETH based and there is no means to adjust.

    What you can do is create a daily bar type from 1-minute bars, so create a 1440 minute bar as the added data series and then it will use whatever trading hours you apply to it.

    Please note that depending on your data provider and depending on the instrument, if the instrument is a futures type, the daily bar close value may actually be the daily settlement price so a 1440 minute bar close would not be the same close price as a daily bar. This may or may not be significant to you but wanted to ensure you know of this potential difference.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thankyou Paul

      This was excellent help.
      The additional info about the Daily Settlement Close was very valuable time saver!
      I do see it randomly which I did not expect to in Forex (must be weekends) and I would have assumed it was something in my code.

      Comment


        #4
        Thanks you all. I was able to follow this thread to add dataseries for the pit session only to make that OHLC available to primary dataseries for evening trading.

        AddDataSeries( this.Instrument.FullName, new BarsPeriod{ BarsPeriodType = BarsPeriodType.Minute, Value = 450 }, "CME US Index Futures RTH");
        if (BarsInProgress == 1)
        {
        Print(string.Format("CurrentBar1 {0} Opens {1} Highs {2} Lows {3} Closes {4} ", CurrentBar, Opens[1][0], Highs[1][0], Lows[1][0], Closes[1][0] ));
        }

        Great resources here!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by nicthe, 08-23-2023, 07:53 AM
        7 responses
        195 views
        0 likes
        Last Post nicthe
        by nicthe
         
        Started by nicthe, Today, 09:24 AM
        0 responses
        4 views
        0 likes
        Last Post nicthe
        by nicthe
         
        Started by stalt, 12-28-2015, 01:36 PM
        6 responses
        1,536 views
        0 likes
        Last Post giulyko00  
        Started by Tburg1073, Today, 08:36 AM
        0 responses
        5 views
        0 likes
        Last Post Tburg1073  
        Started by alexstox, 10-16-2018, 03:29 PM
        10 responses
        333 views
        0 likes
        Last Post Tburg1073  
        Working...
        X