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.

    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.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by thanajo, 05-04-2021, 02:11 AM
      3 responses
      467 views
      0 likes
      Last Post tradingnasdaqprueba  
      Started by Christopher_R, Today, 12:29 AM
      0 responses
      10 views
      0 likes
      Last Post Christopher_R  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      166 responses
      2,236 views
      0 likes
      Last Post sidlercom80  
      Started by thread, Yesterday, 11:58 PM
      0 responses
      4 views
      0 likes
      Last Post thread
      by thread
       
      Started by jclose, Yesterday, 09:37 PM
      0 responses
      9 views
      0 likes
      Last Post jclose
      by jclose
       
      Working...
      X