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

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 andrewtrades, Today, 04:57 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            6 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            436 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            7 views
            0 likes
            Last Post FAQtrader  
            Started by rocketman7, Today, 09:41 AM
            5 responses
            19 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X