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

Subscribing an event to MarketData.Update results in every trade being reported twice

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

  • NinjaTrader_Jesse
    replied
    Hello pjsmith,

    We don't have documentation for that property so there is no more detail I can provide here other than to avoid using that because its not documented for use. That may be used internally but it is not documented for any type of use case so we can't help on that item. The OnMarketData override is the supported and correct way to get this data in an indicator or strategy.

    I can't provide a suggestion for using OnMarketData optionally based on user input, in general scripts are not intended to be dynamic for data use. For the described use case you would want to make two different scripts if one needs OnMarketData and one does not.

    Leave a comment:


  • pjsmith
    replied
    The documentation specifically warns against leaving an empty OnMarketData , because it wastes significant resources. This is what I am trying to avoid. You have no idea why this does not work as expected on this connection? OnMarketData _might_ be required in the indie, depending on the options selected. Rather than write 2 different indies that have to be swapped, it's far better to programmatically enable/disable on startup, if the option is selected. It can't be commented out, because it is sometimes used, depending on options selected.

    The 'unsupported' response is not very helpful!

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello pjsmith,

    The way you are subscribing to data is not documented/supported. You would need to include the OnMarketData override when using indicators/strategies. The override is the correct way to access this data. If you don't need OnMarketData in the script then you can comment out or remove the override.

    Leave a comment:


  • Subscribing an event to MarketData.Update results in every trade being reported twice

    Hello,

    Testing on an FXCM connection, though I am not sure it is relevant.

    I have been using a handler like this Bars.Instrument.MarketData.Update += OnMarketData; in some places rather than an OnMarketData override. The reason for this is that the override is not always needed and leaving in the code unused is very wasteful as it obviously causes that tick/bid/ask stream to be reported. This works fine, but I have noticed on the FXCM connection, however, that this causes every single trade to be reported twice. Can you advise as to why this might be and any way around it?

    I have attached a completely simplified example to reproduce the issue. Add to a tick chart (is what I am using) and monitor the Output. You will see 2 identical prints for each trade. What am I missing?

    Thanks.
    Attached Files

Latest Posts

Collapse

Topics Statistics Last Post
Started by pjsmith, Today, 10:15 AM
1 response
10 views
0 likes
Last Post NinjaTrader_Gaby  
Started by chnh1, Today, 09:12 AM
1 response
5 views
0 likes
Last Post NinjaTrader_Erick  
Started by joe1689, Today, 09:09 AM
1 response
11 views
0 likes
Last Post NinjaTrader_Erick  
Started by agalindoc, 07-09-2024, 03:18 PM
2 responses
29 views
0 likes
Last Post agalindoc  
Started by franki, 06-12-2024, 11:52 AM
9 responses
63 views
0 likes
Last Post NinjaTrader_Gaby  
Working...
X