Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MarketData subscription providing data for other instruments.

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

  • ntbone
    replied
    I attempted to reduce the code to a minimum amount and I was unable to reproduce the bug. I'll post back here if I am able to make any further progress with this. It still happens in the original code.

    Leave a comment:


  • ntbone
    replied
    I am using the MarketData object as part of a DrawingTool. I create one instance for Instrument A and plot it. Then some time later (has been generally within a minute) I create a second instance on a different chart for Instrument B and plot it. When I first create that second instance on ChartB the handler for A gets B's data. I'll throw together a script and get it to you.

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    Hi ntbone, thanks for your reply.

    My test does add two different instruments, but I'm not sure about re-creating this time gap you have between adding the event handlers. Does the problem go away if you add them continuously?

    Please post a reduced version of your script here, or you can send it into platformsupport at ninjatrader.com and reference "Attn ChrisL" in the body of the email.

    I look forward to hearing from you.

    Leave a comment:


  • ntbone
    replied
    Thanks. I had already done this and verified it. I had a strange bug happening when a second object was created using market data for a different instrument. I printed out a message in my event handler whenever it received an event for an instrument it wasn't expecting. There are a few things that are important to note to reproduce this.
    1. You must be subscribing to different instruments for each MarketData instance
    2. There must be time in between each subscription. Instrument A is subscribed and listening, and then Instrument B must be subscribed and listening.
    The messages only show up briefly during the initial subscription to B. If you cannot reproduce this I may try to throw something together in code that will.

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    Hello ntbone, thanks for your post.

    I did a quick implementation of this and I get the correct instrument from each market data hook. You can check the instrument name with "e.Instrument" in your event handler method. Can you print this data in the output window to see if the instrument is, in fact, being called on the wrong event method?

    The print statement I used was:

    private void MSFTOnMarketData(object sender, MarketDataEventArgs e)
    {
    NinjaTrader.Code.Output.Process("Instrument: " + e.Instrument.ToString() + " " + e.Last.ToString() ,PrintTo.OutputTab1);
    }

    I look forward to hearing of your results.

    Leave a comment:


  • MarketData subscription providing data for other instruments.

    The MarketData object as described here https://ninjatrader.com/support/help...marketdata.htm . My understanding was that the subscription was for that instrument and its Update event handler would only be called for that instrument.

    I created two different MarketData objects with different handlers in different classes. They each subscribed to different instruments. I ended up with strange bugs because I never bothered to check the instrument being passed. I eventually tested the instrument against what I expected and found that sometimes one of them would be called with market updates for the other instrument.

    Code:
    MarketData dataForA = new MarketData(instrumentA);
    dataForA.Update += UpdateHandlerForA;
    
    // some time passes before this is created by a different object.
    
    MarketData dataForB = new MarketData(instrumentB);
    dataForB.Update += UpdtaeHandlerForB;
    
    void UpdateHandlerForA(...)
    {
         // recieves some of the B events but only after B is created and subscribed
    }
    
    
    void UpdateHandlerForB(...)
    {
       // only seems to receive events for B
    }
    Something doesn't appear to be right either with the documentation or the implementation.

    This only seems to happen on first subscribing to the MarketData event, and only seems to happen for the first MarketData object created between the two. In the above example it only seems to affect dataForA, and not dataForB.
    Last edited by ntbone; 05-22-2019, 12:45 PM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by vrewoises, Today, 04:31 AM
0 responses
4 views
0 likes
Last Post vrewoises  
Started by butt_toast, Yesterday, 09:47 PM
1 response
5 views
0 likes
Last Post Leeroy_Jenkins  
Started by vrewoises, Today, 03:33 AM
0 responses
5 views
0 likes
Last Post vrewoises  
Started by devonburto, Today, 03:11 AM
0 responses
2 views
0 likes
Last Post devonburto  
Started by ziemany, Today, 02:54 AM
0 responses
2 views
0 likes
Last Post ziemany
by ziemany
 
Working...
X