Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

About OHLC and OHL indicator on session

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

    About OHLC and OHL indicator on session

    Hi!

    I need to modify a couple of built-in indicators.

    I'm talking about the CurrentDayOHL and the PriorDayOLC indicators.

    I plot them in a 30 minutes chart of the ES mini with two sessions for each calendar day. Both indicators encompass the whole calendar day. The problem is that I need to apply them to each session daily.

    How could I do that?​

    #2
    Hello Gianpiero,

    For any system scripts you want to make modifications to, make a copy of the script first. Open the script in the NinjaScript Editor, right-click, select Save as.

    Then instead of using the sessionIterator.GetTradingDay() time, which is the session end time, not the end of day time, use the sessionIterator.GetTradingDayEndLocal() which is the end of day session end time.

    Below is a link to the help guide.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      Thank you for your quick reply. I did as you suggested, but it still doesn't seem to work. As you can see from the attached screenshot, the highest high and the lowest low are still those of the calendar day. You can see from the background shading that a day is split into two sessions of local time. The first goes from 15:30 to 22:15 CET (which corresponds to the CME RTH from Italy, where I live). The second goes from 22:15 to 15:30 CET the following day and corresponds to the CME ETH session. I need to plot the Highest High, the lowest low, and the mid-price of each session separately.

      Click image for larger version

Name:	image.png
Views:	476
Size:	7.9 KB
ID:	1221259

      Comment


        #4
        This is my Trading Hours Template

        Click image for larger version

Name:	image.png
Views:	399
Size:	72.4 KB
ID:	1221261

        Comment


          #5
          Hello Gianpiero,

          If you print GetTradingDayEndLocal(Time[0]), this is giving the end of day day session close time correctly, is this correct?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Hello Chelsea,

            I get only the close time of the RTH session (in local time), never that of the ETH session, as you can see from this excerpt of the output window:

            Session close time 27/10/2022 22:15:00
            Session close time 27/10/2022 22:15:00
            Session close time 27/10/2022 22:15:00
            Session close time 27/10/2022 22:15:00
            Session close time 27/10/2022 22:15:00
            Session close time 27/10/2022 22:15:00
            Session close time 28/10/2022 22:15:00
            Session close time 28/10/2022 22:15:00
            Session close time 28/10/2022 22:15:00
            Session close time 28/10/2022 22:15:00
            Session close time 28/10/2022 22:15:00​

            I guess this matches the EOD flag in the TradingHours template above. The problem is how to get the time of the last candle in the ETH session, which, in my case, ends at 15:30 CET, when my RTH session begins.
            Last edited by Gianpiero; 10-28-2022, 12:44 AM.

            Comment


              #7
              Hello Gianpiero,

              I'm not certain that I am understanding.

              Are you using the ETH+RTH session template in the chart Data Series window?

              The EOD of day time you specified is 22:15 as shown in the screen you provided in post# 4.

              Are you expecting the end of the session to be a different time than what is specified in the Trading Hours template? It will not be. The trading hours will match what is set for the template in the TradingHours window.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hello Chelsea,

                I guess the attached image reflects precisely what I'm trying to achieve.

                I created a Trading Hours Template to divide each calendar day into two different trading sessions. These are the ETH+RTH CME US IndexFutures exchange times converted in my local time. I manually drew each session's highest and lowest levels. I'm trying to design an indicator that does just that.


                Click image for larger version  Name:	image.png Views:	0 Size:	12.3 KB ID:	1221554
                Last edited by Gianpiero; 10-31-2022, 07:26 AM.

                Comment


                  #9
                  Hello Gianpiero,

                  There are similar existing indicators based on time.
                  https://ninjatraderecosystem.com/use...load/repeater/
                  https://ninjatraderecosystem.com/use...ezonecolors-2/
                  https://ninjatraderecosystem.com/use...color-regions/

                  I would not recommend modifying a Trading hours template so that I does not match the exchange hours. This will modify your data and your charts will not match other traders charts.


                  That said, I am still not understanding the issue you are currently having. Is the print of GetTradingDayEndLocal(Time[0]) providing the correct end of day session close time?
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello Chelsea,

                    I did not modify a Trading hours template. I just created a new one in my local time and converted CT hours into CEST hours, meaning Chicago 8:30 AM is 15:30 CET; that's it.

                    This is the template I'm using:


                    Click image for larger version

Name:	image.png
Views:	453
Size:	27.2 KB
ID:	1221572
                    These are the CME US Futures RTH and ETH sessions combined in a single one expressed in my local time.

                    I implemented the example code for the SessionIterator manual page at https://ninjatrader.com/it/support/helpGuides/nt8/.

                    I adapted the following lines to my needs:

                    Code:
                                      sessionIterator.GetNextSession(Time[0], true);
                    
                                      // store the desired session information
                                      tradingDay = sessionIterator.ActualTradingDayExchange;
                                      beginTime  = sessionIterator.ActualSessionBegin;
                                      endTime    = sessionIterator.ActualSessionEnd;
                    
                                      Print(string.Format("\nBarra n° {0} del {1}\n", barra, Time[0]));
                    
                                      Print(string.Format("\nLocale = {0}", sessionIterator.GetTradingDayEndLocal(Time[0])));
                    
                                      Print(string.Format("La Sessione in corso {0}\nč iniziata alle: {1}\ne finisce alle: {2}",
                                                            tradingDay.ToShortDateString(), beginTime, endTime));​​
                    Then, I applied this new template to a chart and ran the example script. The following lines print all sessions of my template correctly, as you can read in this snapshot of the output window:

                    Click image for larger version

Name:	image.png
Views:	395
Size:	11.5 KB
ID:	1221573

                    All the prints seem to provide the correct beginning and end times for each session.

                    Now, my question is: starting on this base, how can I program an indicator plotting the highest high and lowest low for each session, as I drew manually in the example above?

                    Comment


                      #11
                      Hello Gianpiero,

                      On each bar update save which ever is greater using Math.Max() to a variable to store the current high, and which ever is lesser using Math.Min() to a variable to store the current low.

                      Use a variable to track the current session end time. When this changes, reset the variables tracking the current high and current low to the High[0] or Low[0].

                      If you want to reset on each new session within a trading day, then compare the current session end time. If you want to reset only on a new trading day, compare the end of day session end time.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Thank you very much; I appreciate it. It's still a bit cryptical for my programming skills, but I'll try to figure it out.
                        Last edited by Gianpiero; 10-31-2022, 01:44 PM.

                        Comment


                          #13
                          Hello Chelsea,

                          Would you please elaborate more about:
                          which ever is greater using Math.Max() to a variable to store the current high, and which ever is lesser using Math.Min() to a variable to store the current low.
                          What should I compare with these two functions? Meaning: what arguments to Math.Max() and Math.Min()?​

                          Comment


                            #14
                            Hello Gianpiero,

                            Below are links to the Microsoft documentation found through a google search.



                            These require two values, and will return the max or min of the two values supplied.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Hello Chelsea,

                              After carefully reading your last post, I guess I figured out what to do. I'll code a solution and let you know how it performs.
                              Last edited by Gianpiero; 11-01-2022, 01:57 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              576 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              334 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              553 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              551 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X