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

Problem/bug with OnMarketDepth

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

    Problem/bug with OnMarketDepth

    Hello,

    I'm having problems using OnMarketDepth when the indicator is multi-series.
    To test it take SampleLevel2Book and add
    Add(PeriodType.Tick, 1);
    to the Initialize() function.

    OnMarketDepth is called twice per each event, but BarsInProgress is always 0. I've try to make a workaround using information only once call each two, but doesn't works fine, because some times OnMarketDepth is in line for the same series, instead of alternative (for example initial Inserts), but only sometimes, others doesn't. Kind of a hell :-(

    Hope you can help me with this.

    Best regards and thank you!

    #2
    Hello dazkona,

    Thanks for your post.

    Each bars object will call OnBarUpdate(). In the SampleLevel2Book example, add the BarsInProgress to the existing print statements and you will observe the 1 tick series as BarsInProgress 1 while the chart bars are BarsInProgress 0. Please note that if you have not segmented your code that all references will shift depending on the BarsInProgress, for example the SMA(5) will point to a 5 tick SMA when 1 tick series calls OnBarUpdate.

    Please review the MultiTimeFrame/series part of the helpguide for further clarity: http://ninjatrader.com/support/helpG...nstruments.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your answer.
      The problem is on OnMarketDepth, called per each bar object but with BarsInProgress=0 always, so I cannot filter calls.

      Comment


        #4
        Hello dazkona,

        Thanks for your reply.
        In the "Tips" of the helpguide for OnMarketDepth is this note: "...OnMarketDepth will be called for all unique instruments in your strategy. Use the BarsInProgress to filter the OnMarketDepth() method for a specific instrument. (BarsInProgress will return the first BarsInProgress series that matches the instrument for the event)" Reference link: http://ninjatrader.com/support/helpG...arketdepth.htm

        This means that with added timeframes you would not get different BarsInProgress which matches your observations. You would not then be able to filter in OnMarketDepth() using BarsInProgress.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Then is useless because all of your internal OnMarketDepth is based on previous calls

          Could you suggest me correct approach in this case?

          Thanks.
          Last edited by dazkona; 04-26-2017, 09:11 AM.

          Comment


            #6
            Hello dazkona,

            Thank you for your response.

            Can you provide further detail on what you mean by "previous calls"?

            Going back to the original inquiry, you are using Print() in the OnBarUpdate() method, correct? Or are you using Print() in OnMarketDepth()?

            I look forward to your response.

            Comment


              #7
              Thanks for your time, at the end I made a work around

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by proptrade13, Today, 11:06 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by quantismo, 04-17-2024, 05:13 PM
              4 responses
              30 views
              0 likes
              Last Post quantismo  
              Started by love2code2trade, 04-17-2024, 01:45 PM
              4 responses
              31 views
              0 likes
              Last Post love2code2trade  
              Started by cls71, Today, 04:45 AM
              2 responses
              10 views
              0 likes
              Last Post eDanny
              by eDanny
               
              Started by kulwinder73, Today, 10:31 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Erick  
              Working...
              X