Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculate the High and Low of previous day last bar

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

    Calculate the High and Low of previous day last bar

    Hi,

    Is there a simple way to calculate the Open, Close, High and Low of the last candle of yesterday's trading session?.

    Thanks and regards,

    #2
    Hello Sangui,

    You could wait until the first bar of a session and then save the CurrentBar number minus 1 (for the previous bar which is the last bar of the previous session) and then access that bars information whenever you would like.

    You could also use Bars.IsLastBarOfSession as long as the script is processing with Calculate set to On bar close on an intra-day chart.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      OK, but what about if I am using a chart ETH and I need to calculate the data of the last bar but within the regular trading hours (RTH)?

      Comment


        #4
        Hello Sangui,

        You would need to use a session iterator and get the time of that last bar and then find that bar using the time with .GetBar().



        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I found a way buy using:

          AddDataSeries("ES 06-17", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 5 },"CME US Index Futures RTH");
          Thanks a lot.

          Comment


            #6
            Hello Sangui,

            I would not expect this to work in when outside of trading hours for the RTH trading hours.

            From the help guide:
            'A multi-series indicator / strategy will need to have processed a live tick (inside the respective session template(s)) for all instruments the indicator / strategy hosts, for the script to be seeing OnBarUpdate() calls in State.Realtime'
            https://ninjatrader.com/support/help...arupdateMethod

            This will prevent OnBarUpdate from processing data or sending orders or updating plots during the ETH hours when outside of the RTH hours.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            82 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            43 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            64 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            68 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            56 views
            0 likes
            Last Post CarlTrading  
            Working...
            X