Announcement

Collapse
No announcement yet.

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 herzogvladimir2, Today, 08:10 PM
0 responses
2 views
0 likes
Last Post herzogvladimir2  
Started by giogio1, 04-13-2025, 01:42 AM
2 responses
31 views
0 likes
Last Post giogio1
by giogio1
 
Started by mmenigma, 01-23-2024, 09:37 AM
1 response
86 views
0 likes
Last Post Nin8aTrender  
Started by wbayne333, 02-22-2021, 01:18 PM
6 responses
409 views
0 likes
Last Post Nin8aTrender  
Started by gtheaded, 07-03-2020, 03:47 PM
3 responses
370 views
0 likes
Last Post Nin8aTrender  
Working...
X