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!
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
NinjaTrader
MarketData subscription providing data for other instruments.
Collapse
X
-
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.
-
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:
-
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:
-
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.- You must be subscribing to different instruments for each MarketData instance
- There must be time in between each subscription. Instrument A is subscribed and listening, and then Instrument B must be subscribed and listening.
Leave a comment:
-
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 }
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.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by TheTradingMantis, 10-31-2017, 03:18 PM
|
5 responses
1,250 views
0 likes
|
Last Post
by TheAngryCube
Today, 04:06 PM
|
||
Started by Padan, Today, 02:02 AM
|
9 responses
21 views
0 likes
|
Last Post Today, 03:27 PM | ||
Started by spottysallrite, Today, 11:31 AM
|
7 responses
22 views
0 likes
|
Last Post Today, 03:26 PM | ||
Started by nandhumca, Today, 03:15 PM
|
1 response
4 views
0 likes
|
Last Post Today, 03:23 PM | ||
Started by PopovDS, 03-11-2024, 12:49 PM
|
3 responses
17 views
0 likes
|
Last Post
by PopovDS
Today, 03:16 PM
|
Leave a comment: