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,204 / 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!!!

  #11 (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
hi RJay,

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

No problem, here is a sample.

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

protected override void OnMarketData(MarketDataEventArgs e)

{


if (e.MarketDataType == MarketDataType.Ask )theAsk = e.Price; // Add this line

if (e.MarketDataType == MarketDataType.Bid )theBid = e.Price; // Add this line

if (e.MarketDataType != MarketDataType.Last)return;


// if (e.MarketData.Ask != null) theAsk = e.MarketData.Ask.Price; // comment out this line

// if (e.MarketData.Bid != null) theBid = e.MarketData.Bid.Price; // comment out this line

if(theBid <= 0 || theAsk <= 0) return;


if (e.Price == theAsk) { netVolUp += e.Volume; }
else if (e.Price == theBid) { netVolDown -= e.Volume; }


}


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


RJay

Reply With Quote
The following 3 users say Thank You to RJay for this post:
 
  #12 (permalink)
 Vendor: www.integrity-traders.com 
East Rochester, NY
 
Futures Experience: Intermediate
Platform: NT
 
eDanny's Avatar
 
Posts: 327 since Jul 2009
Thanks: 17 given, 419 received


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

This is the problem. Volume[0] works ok in OnBarUpdate(). If counting your own volume from OnMarketData() the first tick of the bar will be dropped. If the number of contracts in that tick is one, your count will be less that Volume[0] or the VOL indicator by one. If there were three contracts, your count will be three less than VOL shows. This is a problem that shows up if using FirstTickOfBar in OnBarUpdate() or if using code like if(CurrentBar != activeBar) in OnMarketData() to start your count in NT7.

Dan

Reply With Quote
The following user says Thank You to eDanny for this post:
 
  #13 (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



RJay View Post
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.

Just to clarify, This problem is not about your datafeed, it's about how your indicators are constructed.

If your indicators are using bad data values, it won't matter what datafeed your using.

Your indicator displays on the chart will be wrong!!!


Test this for yourselves.

Attached is a test indicator that displays differences between NT's temporary store values and your live feed.

Just open your output window and see what I'm talking about. Every display update is a mismatch.

Seeing is Believing,

RJay

Attached Files
Register to download File Type: cs AA_RJay_OnMarketData_Test.cs (11.6 KB, 73 views)
Reply With Quote
 
  #14 (permalink)
Elite Member
Denver, CO
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: NinjaTrader Brokerage
Favorite Futures: ES
 
NinjaTrader's Avatar
 
Posts: 1,260 since May 2010
Thanks: 153 given, 1,890 received

RJay,
You are correct that if you are to use OnMarketData() and you wish to do value comparisons you should store local values in your indicator/strategy. This is expected and has always been the case and is by design. We have advised developers of this in the past but in further research, I see this critical point should have been clearly documented and it will be going forward.

Here are a few points of clarification:

- OnMarketData() is guaranteed to be called in the correct sequence for all level I market data events received from the underlying data source (no data is ever dropped)
- e.MarketDataType determines what data type (bid, ask, last etc…) changed and triggered the call to OnMarketData()
- You should store local variables and update them as OnMarketData() is fired based off the data type that was changed
- e.MarketData can be ignored (if doing comparisons) since values can and likely will be ahead of the data type/value that triggered OnMarketData()
- This is because the underlying MarketData object can be updated on different threads and reflects the most recent values received (you of course will get a OnMarketData() call for these events subsequently)
- And as I replied to you before, FirstTickOfBar is only relevant in the scope of OnBarUpdate()

Ray

Reply With Quote
The following 4 users say Thank You to NinjaTrader for this post:
 
  #15 (permalink)
Market Wizard
Bangkok
 
Futures Experience: Intermediate
Platform: MultiCharts.NET, S5, Ninj
Broker/Data: AMP, S5, IB
Favorite Futures: ES
 
DionysusToast's Avatar
 
Posts: 2,671 since Nov 2010
Thanks: 777 given, 8,738 received
Forum Reputation: Legendary

Many thanks to the OP on this.

I noticed yesterday that something wasn't right on the ES. I have a couple of tools & one of them uses e.MarketData.Bid.Price;

I have been scratching my head all morning looking at code that should work - now I know why it doesn't.

Testing tonight - but based on the symptoms in the OP - this fits my problem perfectly.

DT

Reply With Quote
 
  #16 (permalink)
Membership Temporarily Revoked
Los Angeles, CA
 
Futures Experience: Intermediate
Platform: Ninjatrader7
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: ES
 
grimReaper's Avatar
 
Posts: 50 since Nov 2011
Thanks: 3 given, 12 received

Did NT fix this?

I haven't encountered this problem (yet), but perhaps this would increase smoothness:



 
Code
protected override void OnMarketData(MarketDataEventArgs e){

      MarketDataEventArgs L1DataEvents = e;

      if (L1DataEvents.MarketDataType == MarketDataType.Ask)newAsk = L1DataEvents.Price;

...

}

Reply With Quote
 
  #17 (permalink)
Elite Member
Denver, CO
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: NinjaTrader Brokerage
Favorite Futures: ES
 
NinjaTrader's Avatar
 
Posts: 1,260 since May 2010
Thanks: 153 given, 1,890 received


grimReaper View Post
Did NT fix this?

I haven't encountered this problem (yet), but perhaps this would increase smoothness:



 
Code
protected override void OnMarketData(MarketDataEventArgs e){

      MarketDataEventArgs L1DataEvents = e;

      if (L1DataEvents.MarketDataType == MarketDataType.Ask)newAsk = L1DataEvents.Price;

...

}

On post #14 I clarified the architecture and how to properly handle on market data comparisons in an asynchronous environment. There was nothing to fix.

Reply With Quote
 
  #18 (permalink)
Trading Apprentice
United Kingdom
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: NQ
 
Posts: 1 since Jun 2017
Thanks: 0 given, 0 received

help

hi has anyone fix this as I'm trying to make an Indicator that will let me see the sales in the candle

Reply With Quote
 
  #19 (permalink)
Elite Member
N.Texas
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Global Futures
Favorite Futures: ZB
 
freedomtrader's Avatar
 
Posts: 39 since Aug 2010
Thanks: 173 given, 6 received


lance80 View Post
hi has anyone fix this as I'm trying to make an Indicator that will let me see the sales in the candle

Hey lance80

Have you checked out NT8 downloads?
There are several that will show you orderflow/footprint [" the sales in the candle" ] ie;
https://futures.io/local_links_sort.php?catid=27&filter=&sort=d&page=1&pp=10&keyid=1210

Good luck

Reply With Quote

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)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

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 02:23 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-15 in 0.15 seconds with 20 queries on phoenix via your IP 54.226.132.197