Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars.GetDayBar(1).Close for multi-instrument

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

    Bars.GetDayBar(1).Close for multi-instrument

    hi,

    I'm trying to add 2nd instrument to the program,

    under Initialize(),
    Add("ES 03-12", PeriodType.Minute, 5);

    any idea how can i get px change this additional instrument??

    Closes[1][0] - Bars.GetDayBar(1).Close ??

    if i use Bars.GetDayBar(1).Close, it will gimme the previous closing px of Closes[0][0],

    many thanks,

    Adam

    #2
    Hi Adam,
    Thanks for the post. Can you please clarify what calculation you're looking for?
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      hi Ryan,

      thanks for fast reply,

      im trying to calculate price change relative to previous day close,

      thanks,

      Comment


        #4
        I don't feel you would need a multitime frame script for this. The last price is available with value Close[0] when CalculateOnBarClose = false. You can then make comparisons with this value and the built in PriorDayOHLC()


        GetDayBar() is similar to this, but is intended for session data beyond the current, and previous day.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          thanks for telling me about the PriorDayOHLC(), i guess i make you confuse, my bad,

          the case like this, im trying to print 2 instrument price changes to output window at the same time , let say "msft" and "intel", 5 minutes bars, price change = close[0] - PriorDayOHLC().PriorClose[1],

          under "if( BarsInProgress == 0)", PriorDayOHLC().PriorClose[1] is the prior closing price for the default instrument, "msft"

          my question is how can i get PriorDayOHLC().PriorClose[1] for "intel"??

          Comment


            #6
            Thanks for clarifying. I'm happy to help. You would need to include an Add() statement adding intel. You can access its values with Closes, or filtering updates within a specific BarsInProgress, which would allow you to access the same PriorDayOHLC.

            There is a sample multi instrument strategy available through Tools > Edit NinjaScript > Strategy. Documentation for this is here:
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            157 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            91 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            143 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            131 views
            1 like
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            107 views
            0 likes
            Last Post CarlTrading  
            Working...
            X