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

Adding Daily Data to a Strategy

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

    Adding Daily Data to a Strategy

    I am trying to add 30 days of daily data to my strategy, regardless of how much 1 minute data my strategy is using (testing on 1 day). So on State.Configure I have


    Code:
    var dailyPeriod = new BarsPeriod()
    {
         BarsPeriodType = BarsPeriodType.Day,
         Value = 1
    };
    AddDataSeries(Instrument.ToString(), dailyPeriod, 30, "Default 24 x 5", false);
    I want to use the daily data to calculate daily pivot points. This doesn't seem to work. Been wrestling with this for quite some time, any help would be greatly appreciated.

    #2
    Hello robbersdog,

    Welcome to the NinjaTrader forums!

    I'm not able to reproduce.

    Attached is a test script and the output from prints in the the output window saved to a text file.

    I'm seeing the first day bar as 8/6/2021.

    '8/6/2021 10:00:00 PM | BarsInProgress: 1, CurrentBar: 0'
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thank you, that is helpful. I'm still struggling with calculating some data off of daily bars. All I want to do is get the previous days OHLC. I have tried using BarsArray[1] but with no success. Could you provide a sample of how to get the previous days OHLC? I am running the strategy on minute bars.

      Regards
      Robbersdog

      Comment


        #4
        Hello robbersdog,

        Thank you for your reply.

        You could just use the Prior Day OHLC indicator to get those values without needing daily bars:

        https://ninjatrader.com/support/help...r_day_ohlc.htm

        However, to get the OHLC of a secondary daily data series, you'd want to check Opens[1][0], Highs[1][0], Lows[1][0] or Closes[1][0] if running OnBarClose, and Opens[1][1], Highs[1][1], Lows[1][1] or Closes[1][1] if running OnPriceChange or OnEachTick.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hi Kate,

          Thanks for the reply. I've tried both of those but still not getting the data I'm expecting. This is an example of what I am looking for, using instrument ES 12-21 on the trading day closing on 17th Sep 2021, starting on 16th.The strategy kicks off at 17:00 (16th Sep), and the first 2 minute candle closes at 17:02. When I try to access previous day OHLC I would expect 4476, 4478.50, 4433.25, 4464.25. Accessing the examples above I get the OHLC for the previous bar, specifically OHLC of 4437, 4477.75, 4427.50, 4472. It seems like because the market opens on the 16th it gives me 15th data, even though technically I am currently on 17th Sep trading day.

          How do I get candle 16th OHLC as the market opens on the 16th for trading day ending 17th?

          Regards
          Robbersdog

          Comment


            #6
            Hello robbersdog,

            Thank you for your reply.

            Keep in mind you'll need to have at least 1 day of data loaded on the chart prior to starting the strategy in order to get the prior daily bar or prior OHLC value. The following example requires you to load 2 days of 2 minute bars to function.

            I'm attaching a simple example that uses both tactics (a daily series and the Prior Day OHL to print prior day OHLC prices. You'll notice that the close price differs between the two - this is because daily bars use the settlement adjusted closing price whereas intraday bars do not.

            Please let us know if we may be of further assistance to you.
            Attached Files
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by SydniBuck, Today, 12:54 AM
            0 responses
            6 views
            0 likes
            Last Post SydniBuck  
            Started by ketostrongbuyno, Yesterday, 11:50 PM
            0 responses
            10 views
            0 likes
            Last Post ketostrongbuyno  
            Started by ReinaKutch, Yesterday, 11:08 PM
            0 responses
            9 views
            0 likes
            Last Post ReinaKutch  
            Started by JackyThur, Yesterday, 10:51 PM
            0 responses
            10 views
            0 likes
            Last Post JackyThur  
            Started by sjeffblack, Yesterday, 01:22 PM
            2 responses
            31 views
            0 likes
            Last Post sjeffblack  
            Working...
            X