Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fetch the price of another instrument within a strategy

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

    Fetch the price of another instrument within a strategy

    Hi,
    I am writing a strategy for "instrument A" and I need:
    - the price of "instrument B" the day before at 23:00
    - the price of B the same day at 3:00

    What is the most simple way to get these values?

    Thanks

    #2
    Hello Vincere,

    Thanks for your post and welcome to the NinjaTrader forums!

    You would need to add the "instrument B" using AddDataSeries to your strategy, reference: https://ninjatrader.com/support/help...dataseries.htm You would need to decide what type bars to add, ie: 1 minute, 5 minute, daily, etc.

    To obtain the price from 23:00 on the previous day, your code would need to use a time filter so that at 3:00 you can pull the value of instrument B at 3:00 (which would be Closes[1][0]) and then "instrument B" at 23:00 the day before. To obtain data from 23:00 the day before you could use GetBar(): https://ninjatrader.com/support/help...us/?getbar.htm where you specify a date/time and the method returns the 'bars ago" that the bar occurred which you can then use to obtain the bar value (see the example in the help guide).

    Working with a multi-instrument script can be complex and we recommend a good read of: https://ninjatrader.com/support/help...nstruments.htm

    Comment


      #3
      Hi Paul,

      Thanks for the quick answer! I should have had a look at the documentation before asking. It's well explained.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      132 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      65 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X