Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

52 week High/Low and Current Session's High/Low

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

    52 week High/Low and Current Session's High/Low

    I'm interested in obtaining the 52 week high/low and the current session's high/low values for my strategy.

    I'm using a one minute chart as my primary chart and I've used Add(PeriodType.Day,1) and Add(PeriodType.Week,52) in Initialize() to obtain the daily and 52 week chart values. The Day chart is therefore BarsArray[1] and the Week chart is BarsArray[2] (unless I'm mistaken).

    For the current session's values I've tried:
    double dayhigh = CurrentDayOHL().CurrentHigh[0];
    double daylow = CurrentDayOHL().CurrentLow[0];
    and
    double dayhigh = Highs[1][0];
    double daylow = Highs[1][0];
    and
    double dayhigh = BarsArray[1].GetHigh(0);
    double daylow = BarsArray[1].GetLow(0);

    Each of these returns a value, but it is not consistent with the actual values of the market.

    Similarly, I've tried the following for the 52 week high and low values:
    double the52weekhigh = Highs[2][0];
    double the52weeklow = Lows[2][0];
    and
    double the52weekhigh = BarsArray[2].GetHigh(0);
    double the52weeklow = BarsArray[2].GetLow(0);

    And, again, while results are presented, they are not consistent with reality.

    Put simply, I just want to obtain these values (the current session's high and low and the 52 week high and low). How can I do that, please?

    Thanks for your assistance.

    #2
    cmt_Robert, which primary chart and sessions are you working on testing this?

    You would need to keep in mind when comparing that your daily and higher charts will be build strictly from daily data using the provider native session hours (selected template in NT for those would not affect bars building). While the CurrentDay methods all run off the minute data series working via the session definitions to limit trading hours.

    So depending on your provider and the native daily bar data session used > you could see different values comparing strictly to your intraday.

    Comment


      #3
      Current Session and 52 Week High and Low

      Thank you for your response, Bertrand.

      As mentioned, I'm using a one minute chart as my primary chart. I'm not sure what you mean by "which sessions". I'm charting the ES for this particular strategy.

      My concern is that the results which I am seeing are often 2 full points or more away from the values presented by ThinkOrSwim or Yahoo Finance (each of which is consistently within a quarter point of the other). It makes me question if I am using the right code.

      To be certain that I'm not missing something, would you please provide me with a supported way of obtaining the high and low of the current session and a 52 week high and low?
      Last edited by cmt_Robert; 09-05-2014, 02:23 PM.

      Comment


        #4
        Hi cmt_Robert,

        Bertrand is asking about the session template. This may change the high and the low by changing the hours the strategy is trading.

        To find the session template used:
        Right-click the chart -> select Data Series... -> on the right look for session template.

        The default session template for the ES (<use instrument settings>) is the CME US Index Futures ETH.

        It may be that TDA is using the RTH hours instead of the ETH hours.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,

          Thank you for following up. I will confirm that the session template is consistent.

          Just so that I don't continue to bang my head against a wall, would you please confirm the syntax of the commands that I should be using to obtain the Session high/low and the 52 Week high/low values? You'll note that I have given several examples of things that I've tried and nowhere has a NinjaTrader_Person commented on any of my examples to say "Yep, that's right" or "Nope, wayyyyyy off!"

          Thanks.

          Comment


            #6
            Hi cmt_Robert,

            To find the high and low of the day your usage is correct:
            double dayhigh = CurrentDayOHL().CurrentHigh[0];
            double daylow = CurrentDayOHL().CurrentLow[0];
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              And for the 52 week high/low...?

              Comment


                #8
                Hi cmt_Robert,

                Sorry I didn't include that.

                The 52 week high / low is captured a bit differently.

                This actually has to come from a live data feed (or from a file if you want to go that route).

                To get this you will need OnFundamentalData. This runs when the fundamental data, like 52 week high, or the daily avg, etc... are received; and the first burst of info usually comes when you first connect / load a chart.

                For example:
                protected override void OnFundamentalData(FundamentalDataEventArgs e)
                {
                Print(FundamentalDataType.High52Weeks);
                Print(FundamentalDataType.Low52Weeks);
                }

                Below is a link to the OnFundamentalData.
                http://www.ninjatrader.com/support/h...mentaldata.htm
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you!

                  So, if I understand correctly, the 52 week approach you've given here won't work in backtesting (in Market Replay, for example)?

                  And can you please expand on "(or from a file if you want to go that route)"? Especially if I can use that method for backtesting.

                  Comment


                    #10
                    Hi cmt_Robert,

                    From my understanding, this will work in replay, but will not work with the strategy analyzer and will not work with historical data on a chart.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks again, Chelsea.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      650 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      370 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      109 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      574 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      577 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X