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

OnMarketData

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

    OnMarketData

    hi,
    is it possible to get data with OnMarketData of an different instrument on any chart-instrument?
    have it for my chart-instrument, but need a second say QQQ in the same chart.
    br
    Attached Files
    Last edited by mate41; 05-20-2016, 08:40 AM.

    #2
    Hello mate41,

    Thank you for writing in.

    OnMarketData() will be called for all unique instruments in your strategy. If you wish OnMarketData() to provide information about a different instrument, you will need to Add() that instrument in Initialize().

    More information about Add() can be found here: https://ninjatrader.com/support/help.../nt7/?add3.htm

    More information about OnMarketData() can be found here: https://ninjatrader.com/support/help...marketdata.htm

    Lastly, more information about multi-time frame and multi-instrument strategies can be found here: https://ninjatrader.com/support/help...nstruments.htm

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks, i use already OnMarketData on the first instrument, no problem.
      But when i add a second instrument, how can i call the types of the second instrument ?

      Comment


        #4
        Hello mate41,

        With multi-time frame and instrument strategies, OnMarketData() will be called for all unique instruments in your strategy. Use the BarsInProgress to filter the OnMarketData() method for a specific instrument. (BarsInProgress will return the first BarsInProgress series that matches the instrument for the event)

        For example:
        Code:
        protected override void Initialize()
        {
             // AAPL will be at BIP 1
             Add("AAPL", PeriodType.Minute, 1);
        }
        
        protected override void OnMarketData(MarketDataEventArgs e)
        {
             // if AAPL has called OnMarketData(), do something
             if (BarsInProgress == 1)
                  // do stuff
        }
        For more information about BarsInProgress, please take a look at this help guide link: https://ninjatrader.com/support/help...inprogress.htm
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          If i understand i can only use 1 instrument, not 2 at the same time ??

          Comment


            #6
            Hello mate41,

            There is no limitation to how many instruments you can add to a script. However, please note that some data providers may place a limitation on how many instruments you are requesting real-time data from at once.
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              Thanks, so i've to detect if one or another is in progress. I wonder when they are both on +/- the same time.
              I'll try it.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by f.saeidi, Today, 11:02 AM
              1 response
              1 view
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by geotrades1, Today, 10:02 AM
              4 responses
              11 views
              0 likes
              Last Post geotrades1  
              Started by rajendrasubedi2023, Today, 09:50 AM
              3 responses
              15 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by lorem, Today, 09:18 AM
              2 responses
              11 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by geddyisodin, Today, 05:20 AM
              4 responses
              30 views
              0 likes
              Last Post geddyisodin  
              Working...
              X