• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ISSUE: OnMarketData() & OnMarketDepth()

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

    ISSUE: OnMarketData() & OnMarketDepth()

    In NT7, if an indicator inherits the OnMarketData() method from a superclass, then at run time the indicator will be sent the message OnMarketData() whenever there is a level 1 market event. The situation with respect to OnMarketDepth() is analogous, with the difference being that the OnMarketDepth() message will be sent to the indicator whenever there is a level 2 market event (a price quote change.)

    However, that is not what currently happens in NinjaTrader 8: Unless an indicator directly implements the OnMarketData() method, it will not be sent the message OnMarketData() whenever there is a level 1 market event, and unless it directly implements OnMarketDepth(), it will not be sent the message OnMarketDepth() whenever there is a level 2 market event.

    This is a problem for several reasons:

    1) It's different behavior than NT7.

    2) It's a violation of the principles of OO, and therefore creates behavior which almost no one will expect. So it also violates the principle of least surprise.

    3) To work around the problem, one must either reimplement the inherited method in the subclass (which is bad OO diesign, and against software engineering principles) or else one must implement the method so that all it does is invoke the version of the method it inherits (which many software engineers would think was a bad thing to do, if they saw such code in a code review.)

    I strongly suspect that the intent was to optimize the environment so that indicators which don't need to be scheduled to receive level 1 and/or level 2 market event notifications can be left out of the event notification dispatch queue. And that's a commendable design choice. However, the current implementation goes too far, because it apparently assumes that indicators which don't directly implement the OnMarketData() method and/or the OnMarketDepth() method don't need to be notified of level 1 and/or level 2 market data events. But that assumption is false. And there are more sophisticated alternative approaches to achieve the same benefit without any of the downsides of the current design:

    1) If an indicator does implement OnMarketData() directly, then add it to the dispatch queue for level 1 market data events. Otherwise, traverse up the class inheritance hierarchy until a class which does directly implement the method is found. If that class is not the original definer (it's an override,) then add the indicator to the dispatch queue. Otherwise, don't.

    2) Define a new boolean configuration parameter which controls whether or not an indicator should be added to the level 1 market data event dispatch queue. The default value should be false. The benefit of this approach is that some indicators may want/need to only handle level 1 market data events when the user so requests, and not otherwise.

    Whatever approach is chosen, it should be the same for all the various types of market data event notifications (Occam's Razor.)

    #2
    Hello strategesis,

    Thank you for your patience.

    We are looking into this matter and we will follow up with details.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for pointing that out. We did make a decision to clean that up a bit but it is unnecessarily restricting considering we have customers that do this in NT7. We will change this for the next beta to be more like NT7.
      BrettNinjaTrader Product Management

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rickyblah12, Today, 01:01 PM
      0 responses
      7 views
      0 likes
      Last Post rickyblah12  
      Started by dadarara, Today, 12:18 PM
      0 responses
      8 views
      0 likes
      Last Post dadarara  
      Started by joemiller, Today, 07:33 AM
      0 responses
      8 views
      0 likes
      Last Post joemiller  
      Started by TheGameOfProbabilities, 07-18-2019, 06:56 AM
      7 responses
      38 views
      0 likes
      Last Post DaveS
      by DaveS
       
      Started by claxxical, Yesterday, 10:00 PM
      0 responses
      12 views
      0 likes
      Last Post claxxical  
      Working...
      X