Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Closes[0][0] vs PriorDayOHLC().PriorClose[0] with muliple time frames

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

    Closes[0][0] vs PriorDayOHLC().PriorClose[0] with muliple time frames

    in protected override void Initialize


    using Add(PeriodType.Day, 1);

    CalculateOnBarClose = false;


    Let's assume that i test the ES with 1 Minute data based on RTH session template.

    I will enter a enter order a few min after open, if last days' close is above a specific price.

    Does Closes[1][0] mean the Close of the current day or last days' close? (since CalculateOnBarClose = false; i assume PriorDayOHLC().PriorClose[0] and Closes[1][0] are different)


    **Edit**
    I meant Closes[1][0] not Closes[0][0] and switched it
    Last edited by markus1000; 05-16-2012, 10:26 AM.

    #2
    Hello markus1000,
    Closes[0][0] means the closing price of current running bar of the primary data series.


    The first [0] represents the BarsArray, while the second[0] represents the bar lookback period.

    If you want to place an order when current price goes above yesterdays close and you have added a daily data series as the secondary bars array, then please use the below code
    Code:
    if (Closes[0][0] > Closes[1][1])
    {
       //do something.
    }
    Yes, PriorDayOHLC().PriceClose[0] and Closes[0][0] are not the same thing.

    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      sorry i meant Closes[1][0] not Closes[0][0] given i added Add(PeriodType.Day, 1);

      will Closes[1][0] be recalculated when the market opens or only my primary series?

      Comment


        #4
        Hello markus1000,
        If your connectivity provider provides realtime updates for daily bar series then Closes[1][0] will too will be updated like your primary series (provided CalculateOnBarClose = false).
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          i run a backtest on FDAX ##-## using minute data

          protected override void Initialize()
          {


          Add(PeriodType.Day, 1);

          CalculateOnBarClose = false;
          }


          protected override void OnBarUpdate()
          {
          Print("X"+Time[0].Day);
          Print (Closes[1][1]);
          Print("Y"+Time[0].Day);
          Print (PriorDayOHLC().PriorHigh[0]);


          strangely the output for PriorDayOHLC() always shows the close of the prior day, no matter if i chose High, low, close or open.

          The method Closes[1][1] gives my the correct values in the output window.

          But when i insert Closes[1][1] for PriorDayOHLC().PriorClose0] in my strategy the results are completely off, even with correct values in the output window.


          And after substituting all PriorDayOHLC(). and CurrentDayOHL() with values based on the the alternative syntax, my code is like 70% faster (but the results are wrong)
          Last edited by markus1000; 07-10-2012, 02:06 AM.

          Comment


            #6
            Hello marcus1000,
            PriorDayOHLC indicator works on Intraday data only. Your secondary bar series is of daily data.

            Also since you are testing the code in a multi series environment please further filter your code with the BarsInProgress property.

            JoydeepNinjaTrader Customer Service

            Comment


              #7
              but my primary data series is intraday, and the times when i want to use daily data i can address it with Closes[1][0], i mean i could use the BarsInProgress command. but both methods should be equal, or am i missing something?
              Last edited by markus1000; 07-10-2012, 04:55 AM.

              Comment


                #8
                Hello marcus1000,
                OHLC calculated from intraday data can vary from the OHLC of a daily bar. Some common factor for this are:
                What session template the data is being called for. Daily bars are generally calculated on RTH session template. It is not the case for intraday data (can be RTH or ETH).

                Close of daily bar are based on average weighted price of the last 30 minutes. For intraday data it is the last traded price.
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  ok sounds like the OHLC indicator is the safer bet for my purpose. The last problem is that the OHLC indicator slows things down drastically, im running 10 years on 1 minute data and it takes a while. i could change things to 5 min, but is there another way to speed things up a bit?

                  Comment


                    #10
                    Hello marcus1000,
                    If you run the indicator on a 1 minute chart for 10 years data then it will consume resource. Unfortunately there are no way to speed it up other than to lower the data granularity or reduce the amount of the data loaded.
                    JoydeepNinjaTrader Customer Service

                    Comment


                      #11
                      Hi Joydeep,

                      You mentioned, "Close of daily bar are based on average weighted price of the last 30 minutes." Does NinjaTrader always calculate the daily close internally, or are there conditions under which it uses the values from the data feed? (i.e. does it calculate it internally for real-time data only, or only for strategies). I assumed it would always use the daily bars from the data provider if available.
                      Last edited by infin8loop; 08-24-2012, 10:58 PM.

                      Comment


                        #12
                        Hello infin8loop,
                        NinjaTrader is only a charting/backtesting/trading platform and not a data feed provider. NinjaTrader only plots the data as provided by your connectivity provider/broker.

                        Please refer to this link to know how CME calculates the closing price for different instruments.
                        CME Group is the world's leading and most diverse derivatives marketplace offering the widest range of futures and options products for risk management.
                        JoydeepNinjaTrader Customer Service

                        Comment


                          #13
                          Thanks. That is what I expect. So, does that mean that I should only see the OnBarUpdate method called on daily data series when there is also an entry in the Historical Data Manager for the Last price for the day in question? (I'm seeing NinjaTrader call the OnBarUpdate method for a secondary daily series(BarsInProgress == 1) with the wrong value and no corresponding daily value in the Historical Data Manager). i.e. Where is it getting that value from and why is OnBarUpdate being called if it hasn't received a settlement value from the data provider?

                          Comment


                            #14
                            Hello infin8loop,
                            To assist you further may I know:
                            Are you referring to the the values of the current/running bar or the historical bar?
                            Are you testing the strategy while you are connected, if so may I know who your connectivity provider is?

                            I look forward to assisting you further.
                            JoydeepNinjaTrader Customer Service

                            Comment


                              #15
                              I'm testing an indicator and strategy based off of 1 minute bars with a secondary daily data series added to determine the 'official' settlement price. I'm referring to the values of the daily close (i.e. Closes[1][0]) - both historical and real-time. I'm testing using both RTH and ETH session templates and Kinetick is my data provider.

                              I'm expecting to see a closing value that matches what's in the Historical Data Manager for the daily data however, I'm am seeing the closing value of the last minute bar of the session (i.e. the 2:00 PM CT minute bar for the ZC 12-12).
                              Last edited by infin8loop; 08-28-2012, 09:15 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              669 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              378 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              111 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              575 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              580 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X