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 Balage0922, Today, 07:38 AM
              0 responses
              1 view
              0 likes
              Last Post Balage0922  
              Started by JoMoon2024, Today, 06:56 AM
              0 responses
              6 views
              0 likes
              Last Post JoMoon2024  
              Started by Haiasi, 04-25-2024, 06:53 PM
              2 responses
              19 views
              0 likes
              Last Post Massinisa  
              Started by Creamers, Today, 05:32 AM
              0 responses
              6 views
              0 likes
              Last Post Creamers  
              Started by Segwin, 05-07-2018, 02:15 PM
              12 responses
              1,786 views
              0 likes
              Last Post Leafcutter  
              Working...
              X