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 TraderBCL, Today, 04:38 AM
              2 responses
              12 views
              0 likes
              Last Post TraderBCL  
              Started by martin70, 03-24-2023, 04:58 AM
              14 responses
              105 views
              0 likes
              Last Post martin70  
              Started by Radano, 06-10-2021, 01:40 AM
              19 responses
              607 views
              0 likes
              Last Post Radano
              by Radano
               
              Started by KenneGaray, Today, 03:48 AM
              0 responses
              4 views
              0 likes
              Last Post KenneGaray  
              Started by thanajo, 05-04-2021, 02:11 AM
              4 responses
              471 views
              0 likes
              Last Post tradingnasdaqprueba  
              Working...
              X