NT Providing Bad Price & Volume Data in OnMarketData!!! - NinjaTrader Programming | futures io social day trading
futures io futures trading


NT Providing Bad Price & Volume Data in OnMarketData!!!
Updated: Views / Replies:5,190 / 18
Created: by RJay Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 1  
 
Thread Tools Search this Thread
 

NT Providing Bad Price & Volume Data in OnMarketData!!!

  #1 (permalink)
 Vendor: www.innovative-trading-solutions-online.com 
Hartford, CT. USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: AMP/CQG, Kinetick
Favorite Futures: TF
 
RJay's Avatar
 
Posts: 677 since Jun 2009
Thanks: 726 given, 740 received

NT Providing Bad Price & Volume Data in OnMarketData!!!

In OnMarketData, NT provides temporary values for coders for volume and price, for bid, ask and last.

These values are accessed with the following code.

-----------------------------------------------------------------

e.MarketData.Ask.Price

e.MarketData.Bid.Price

e.MarketData.Last.Price

e.MarketData.Ask.Volume

e.MarketData.Bid.Volume

e.MarketData.Last.Volume

----------------------------------------------------------------

If you are using any of these coding queries in your indicators, your indicators are displaying bad data!!!


Here are a few examples of what is going wrong:


When several ticks arrive at the same time, NT tends to assign all of those trades the same volume even though the trades all had different volumes.

Also, When the market trends strongly in one direction, the bid and ask prices offered fall behind the live market. This
results in last trades for both the bid and the ask, to be tallied, either, all for the bid, or all for the ask.

This really screws up stuff like volume delta calculations!!!!


This problem is persistent in both NT 6.5 and NT7.


The workaround for this problem is to create your own temporary store values from e.Volume and e.Price.

Below are the lines of code that I now use in my indicators.

---------------------------------------------------------------------------------------------------

if (e.MarketDataType == MarketDataType.Ask)ePriceAsk = e.Price;

if (e.MarketDataType == MarketDataType.Bid)ePriceBid = e.Price;

if (e.MarketDataType == MarketDataType.Last)ePriceLast = e.Price;

if (e.MarketDataType == MarketDataType.Ask)eVolumeAsk = e.Volume;

if (e.MarketDataType == MarketDataType.Bid)eVolumeBid = e.Volume;

if (e.MarketDataType == MarketDataType.Last)eVolumeLast = e.Volume;

---------------------------------------------------------------------------------------------------

After I made these changes and put the temporary patch for the CurrentBar/FirstTickOfBar bug into my indicators, my NT7 indicators are now matching the Time & Sales display window tick for tick.


I plan to post a problem report on the NT forum this Monday and hope they will take steps to resolve this issue.

I am also building an indicator that will send all of the bad data mismatches to the output window to help NT confirm the problem.


Comments and feedback are appreciated,


RJay



FYI, All the Bid/Ask volume indicators I have posted here, on this forum, have this problem. I will update them when NT7 is finally released.

Reply With Quote
The following 14 users say Thank You to RJay for this post:
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
CA
 
Futures Experience: Master
Platform: Marketdelta and Ninja
Broker/Data: Velocity
Favorite Futures: NQ
 
Posts: 670 since Apr 2010
Thanks: 64 given, 521 received


Rjay, does this affect the bid/ask ladder in any way according to your research?

Reply With Quote
 
  #4 (permalink)
Elite Member
Portland Oregon, United States
 
Futures Experience: Beginner
Platform: Ninjatrader®
Broker/Data: CQG, Kinetick
Favorite Futures: Gameplay Klownbine® Trading of Globex
 
Zondor's Avatar
 
Posts: 1,327 since Jul 2009
Thanks: 1,246 given, 2,635 received

OnMarketData Method and Gom Volume Ladder

The Gom Volume Ladder depends on bid ask data from the GomRecorderIndicator, which is in turn processed by and passed through the GomDeltaIndicator.

I believe that the code in the OnMarketData method of the GomRecorderIndicator is correct. It agrees with sample code that was posted a couple of years ago in the Ninjatrader forums.

  • If the e.MarketDataType is is e.MarketDataType.Bid, it stores the price associated with that event as the most recent bid price.
  • If the e.MarketDataType is MarketDataType.Ask, it stores the price associated with that event as the most recent ask price.
  • If the e.MarketDataType is MarketDataType.Last, that event means an actual trade has occurred. The price and volume associated with that event are the price and volume of the trade. The price of the trade is compared to the most recent bid and ask prices from the MarketDataType.Bid and MarketDataType.Ask events, to see whether the trade occurred AtAsk, AboveAsk, AtBid, BelowBid, or BetweenBidAsk (these are the strings values associated with the tickType Enum.)

Please let me know if anyone can see any problems with this. It looks fine to me.

Reply With Quote
The following 4 users say Thank You to Zondor for this post:
 
  #5 (permalink)
 Vendor: www.innovative-trading-solutions-online.com 
Hartford, CT. USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: AMP/CQG, Kinetick
Favorite Futures: TF
 
RJay's Avatar
 
Posts: 677 since Jun 2009
Thanks: 726 given, 740 received

Zondor and Micheal H. ,

First, Since The volume ladder uses data from the GomIndicator Recorder, It is not using NT's bad volume / price data.

Here is the GomIndicatorRecorder code clearly showing it using e.Price and e.Volume as its data source.

---------------------------------------------------------------------------------------------

TickTypeEnum tickType;

if (!initBidAsk)
initBidAsk=(ask!=0 && bid!=0);

if ((e.MarketDataType==MarketDataType.Last))
{
tickType=GomFileManager.GetIntTickType(bid,ask,e.Price);
if ((recordingOK)&&(initBidAsk)&& (e.Time>fm.LastTimeInFile))



if ((recordingOK)&&(e.Time>fm.LastTimeInFile))

fm.RecordTick(t,tickType,e.Price,(int)e.Volume);

GomOnMarketDataWithTime(t,tickType,e.Price,(int)e.Volume,FirstTickOfBar);
}

else if (e.MarketDataType == MarketDataType.Ask) { ask=e.Price; }

else if (e.MarketDataType == MarketDataType.Bid) { bid=e.Price; }

-----------------------------------------------------------------------------------------------------

However, The ladder does use FirstTickOf Bar in its code. This means it suffers from the FirstTickOf Bar bug in NT7.When the volume ladder is building live on the chart, it is dropping the first tick of every bar.

When you refresh the chart, it will refresh with the correct data from all the ticks.


NT6.5 should be working just fine.

RJay

Reply With Quote
The following 4 users say Thank You to RJay for this post:
 
  #6 (permalink)
 Vendor: www.innovative-trading-solutions-online.com 
Hartford, CT. USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: AMP/CQG, Kinetick
Favorite Futures: TF
 
RJay's Avatar
 
Posts: 677 since Jun 2009
Thanks: 726 given, 740 received


Zondor View Post
The Gom Volume Ladder depends on bid ask data from the GomRecorderIndicator, which is in turn processed by and passed through the GomDeltaIndicator.

I believe that the code in the OnMarketData method of the GomRecorderIndicator is correct. It agrees with sample code that was posted a couple of years ago in the Ninjatrader forums.

  • If the e.MarketDataType is is e.MarketDataType.Bid, it stores the price associated with that event as the most recent bid price.
  • If the e.MarketDataType is MarketDataType.Ask, it stores the price associated with that event as the most recent ask price.
  • If the e.MarketDataType is MarketDataType.Last, that event means an actual trade has occurred. The price and volume associated with that event are the price and volume of the trade. The price of the trade is compared to the most recent bid and ask prices from the MarketDataType.Bid and MarketDataType.Ask events, to see whether the trade occurred AtAsk, AboveAsk, AtBid, BelowBid, or BetweenBidAsk (these are the strings values associated with the tickType Enum.)

Please let me know if anyone can see any problems with this. It looks fine to me.

Zondor,

The purpose of this thread is to warn everyone away from the code you are advocating in your post.

That code is not updating properly!!!

I am your friend and I am urging you not to use that code until NT effect repairs.

RJay

Reply With Quote
The following user says Thank You to RJay for this post:
 
  #7 (permalink)
Elite Member
San Francisco Bay Area
 
Futures Experience: Intermediate
Platform: NT,TOS,IB
Favorite Futures: ES,CL,TF
 
Posts: 278 since Jun 2010
Thanks: 154 given, 267 received

Folks:

I need some clarifications here.

1. What exactly is the FirstTickOfBar bug which you are referring to? Is it perhaps the issue that the OnMarketData() call back occurs before the OnBarUpdate() (with FirstTickOfBar == true) occurs if the tick results in the end of the current bar?

If that is indeed the case, I prefer this approach since your code gets the tick prior to all the processing associated with OnBarUpdate for the tick which results in a new bar. When an old bar ends and new bar starts, NT has to do book-keeping for closing the previous bar and creating the new bar. I would prefer if my strategy gets that tick sooner than later.

Ideally, NT could first do a quick check to see if the tick results in a new bar and then set the field accordingly. That brings up a new question:

If you have multiple bars for the same instrument in your indicator, does the OnMarketData() trigger multiple times for each Bar or does it trigger only once for each instrument.

2. Regarding the bad values in the OnMarketData:
I think they use a single structure to store values for all the different tick types but only update the one corresponding to the current tick type. This makes sense from an performance point of view. All they do is set the type and the respective fields and reuse the same-structure instead of resetting it or setting it for the latest value for the other fields. Think if it as getting data tick by tick. When you get a Last Tick (trade), you should not be looking at the fields associated with the Bid/Ask.

Reply With Quote
The following 2 users say Thank You to aviat72 for this post:
 
  #8 (permalink)
 Vendor: www.innovative-trading-solutions-online.com 
Hartford, CT. USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: AMP/CQG, Kinetick
Favorite Futures: TF
 
RJay's Avatar
 
Posts: 677 since Jun 2009
Thanks: 726 given, 740 received


aviat72 View Post
Folks:

I need some clarifications here.

1. What exactly is the FirstTickOfBar bug which you are referring to? Is it perhaps the issue that the OnMarketData() call back occurs before the OnBarUpdate() (with FirstTickOfBar == true) occurs if the tick results in the end of the current bar?

If that is indeed the case, I prefer this approach since your code gets the tick prior to all the processing associated with OnBarUpdate for the tick which results in a new bar. When an old bar ends and new bar starts, NT has to do book-keeping for closing the previous bar and creating the new bar. I would prefer if my strategy gets that tick sooner than later.

Ideally, NT could first do a quick check to see if the tick results in a new bar and then set the field accordingly. That brings up a new question:

If you have multiple bars for the same instrument in your indicator, does the OnMarketData() trigger multiple times for each Bar or does it trigger only once for each instrument.

2. Regarding the bad values in the OnMarketData:
I think they use a single structure to store values for all the different tick types but only update the one corresponding to the current tick type. This makes sense from an performance point of view. All they do is set the type and the respective fields and reuse the same-structure instead of resetting it or setting it for the latest value for the other fields. Think if it as getting data tick by tick. When you get a Last Tick (trade), you should not be looking at the fields associated with the Bid/Ask.

Answer to 1.

Version 7 beta22 Dropping Ticks??? - Page 2 - NinjaTrader Support Forum

Answer to 2.

When determining if a Last Tick occured at above ask, ask, between ask and bid, bid, below bid, you have to look at the most recent bid and ask ticks.

If the bid and ask ticks are not updating in real time, you got a problem.

Reply With Quote
The following 2 users say Thank You to RJay for this post:
 
  #9 (permalink)
Elite Member
San Francisco Bay Area
 
Futures Experience: Intermediate
Platform: NT,TOS,IB
Favorite Futures: ES,CL,TF
 
Posts: 278 since Jun 2010
Thanks: 154 given, 267 received



I think the conversation confirms what I wrote in the previous post. The FirstTickOfBar is only valid in the context of OnBarUpdate().

It is not valid on the OnMarketData event. Making it valid would require NT to pre-process the tick and then establish a new bar is being formed prior to sending the OnMarketData event. This requires more computation and would delay the OnMarketData event.

NT is prioritizing the OnMarketData event over OnBarUpdate. They could split the processing of OnBarUpdate into parts; a pre-processing step which checks whether a new bar is being formed which is called prior to OnMarketData() and then the rest of the stuff which is done OnBarUpdate().


Quoting 

Answer to 2.

When determining if a Last Tick occured at above ask, ask, between ask and bid, bid, below bid, you have to look at the most recent bid and ask ticks.

If the bid and ask ticks are not updating in real time, you got a problem.

Rjay:

The point I was trying to make was that the fields which are valid is based on the context of the event type. If the event is of type last, then looking at bid info for that event is not valid. NT could return an exception saying that the field does not even exist; but that will add more code and will slowdown the system.

That is why GOM stores the price stores the last bid/ask locally based on the type of tick. Your expectation of the last bid/ask price and volume data being set correctly on a Last event is not consistent with the type of event OnMarketData() is designed for.

Think of it in terms of a tick stream. If you have a series which says: B,A,A,L,B,A then to check for the Bid fields on event 4 (L) is not valid. You need to check for the value passed on the last Bid event (event 1) which you should store locally.


Last edited by aviat72; October 17th, 2010 at 09:55 PM.
Reply With Quote
 
  #10 (permalink)
Elite Member
Portland Oregon, United States
 
Futures Experience: Beginner
Platform: Ninjatrader®
Broker/Data: CQG, Kinetick
Favorite Futures: Gameplay Klownbine® Trading of Globex
 
Zondor's Avatar
 
Posts: 1,327 since Jul 2009
Thanks: 1,246 given, 2,635 received



RJay View Post
Zondor,

The purpose of this thread is to warn everyone away from the code you are advocating in your post.

That code is not updating properly!!!

I am your friend and I am urging you not to use that code until NT effect repairs.

RJay


hi RJay,

Please post sample code or pseudo code showing correct method to use, thanks!

Reply With Quote
The following user says Thank You to Zondor for this post:

Reply



futures io > > > > > NT Providing Bad Price & Volume Data in OnMarketData!!!

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using OnMarketData() on Historical data with a recording engine gomi NinjaTrader Programming 115 March 6th, 2011 07:11 PM
Price, Volume & the DOM - Live Trading Journal ZTR Elite Trading Journals 822 October 6th, 2010 03:19 PM
False volume data with IB and NT 7.0.0.20 Fat Tails NinjaTrader 13 September 9th, 2010 08:47 PM
Price & Volume Trading Journal ZTR Trading Journals 117 February 21st, 2010 04:02 AM
Writing & reading data into/out of NT Saroj NinjaTrader Programming 1 September 12th, 2009 04:55 PM


All times are GMT -4. The time now is 08:41 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-12 in 0.20 seconds with 20 queries on phoenix via your IP 54.90.207.75