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

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 aussugardefender, Today, 01:07 AM
            0 responses
            3 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            238 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            9 responses
            384 views
            1 like
            Last Post Gavini
            by Gavini
             
            Started by oviejo, Today, 12:28 AM
            0 responses
            4 views
            0 likes
            Last Post oviejo
            by oviejo
             
            Started by pechtri, 06-22-2023, 02:31 AM
            10 responses
            125 views
            0 likes
            Last Post Leeroy_Jenkins  
            Working...
            X