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 cre8able, 02-11-2023, 05:43 PM
              3 responses
              236 views
              0 likes
              Last Post rhubear
              by rhubear
               
              Started by frslvr, 04-11-2024, 07:26 AM
              8 responses
              113 views
              1 like
              Last Post NinjaTrader_BrandonH  
              Started by stafe, 04-15-2024, 08:34 PM
              10 responses
              46 views
              0 likes
              Last Post stafe
              by stafe
               
              Started by rocketman7, Today, 09:41 AM
              3 responses
              11 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by traderqz, Today, 09:44 AM
              2 responses
              10 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X