Programming Indicators Using OnMarketData in NT7!!! - NinjaTrader Programming | futures io social day trading
futures io futures trading


Programming Indicators Using OnMarketData in NT7!!!
Updated: Views / Replies:2,505 / 3
Created: by RJay Attachments:0

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
 
Thread Tools Search this Thread
 

Programming Indicators Using OnMarketData in NT7!!!

  #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

Programming Indicators Using OnMarketData in NT7!!!

Hi All,

If you have been following along, you know that ...

In NT 6.5, OnBarUpdate and OnMarketData along with FirstTickOfBar and CurrentBar all get along nicely!!

In NT7, all that has changed.

OnBarUpdate and OnMarketData are no longer synchronized!!!

FirstTickOfBar and CurrentBar do not do the job they once did in 6.5.

In NT7, FirstTickOfBar and CurrentBar should be renamed to SecondTickOfBar and CurrentBarMostOfTheTime!!!

When I asked NT to allow access to FirstTickOfBar and CurrentBar directly from OnMarketData in NT7 instead of gleaning updates from OnBarUpdate, They said no.

This is a huge problem for any indicators using data from OnMarketData. Data from the first tick of every bar is slipping through the crack and is not being processed by the indicator.

I asked NT if there was any way to access bar data directly from OnMarketData??

They responded that it wasn't their job to write my programs for me!!!

My attempts to create code to access bar data from the indicator failed.

I then posted a "hold current tick till next tick" code to process the first tick of each bar when the second tick arrived as a possible solution.

This solution was overly complicated, and was not completely accurate 100 percent of the time.


Now Fast forward to the weekend of 12/12/2010.

A programmer with a similar problem posted code at the NT forum requesting help.

In his code, he was directly accessing bar data from inside the indicator program.

I dropped everything I was working on to look into this!!!

Yea, it turns out that NT had existing code to access bar data and had chosen not to share this with me!!!!

After several hours of testing I made a breakthrough. I am now able to query the current bar status, of the chart, from inside OnMarketData, prior to processing incoming data from the data feed for every tick.


It looks like this:


protected override void OnMarketData(MarketDataEventArgs e)

{


if(Bars.Count != activeBar)


{


TotalVolLast = 0;

activeBar = Bars.Count;

}


if ((e.MarketDataType == MarketDataType.Last)) TotalVolLast+= e.Volume;


Values[0].Set(TotalVolLast);


double volume = Volume[0];


}



Pretty simple!!!! Huh!!! So easy a caveman can do it!!!!


Next, I found that bad plot data was outputting from OnBarUpdate and was overriding the correct plot output from OnMarketData.

What's causing this??? Your guess is as good as mine!!!!

This sort of sucked, so I removed that code from OnBarUpdate.

Since there is no historic data to load and CurrentBar and FirstTickOfBar are of no use, and having problems plotting from OnBarUpdate, UnBarUpdate now looks like this in all my volume indicators.


protected override void OnBarUpdate()

{


}



Yea, so much for OnBarUpdate!!!

Now all my volume indicators totals matched the VOL indicator on that chart!!!


I opened a second identical chart, with just a few of my indicators.

Indicators on the second chart did not match the same indicators on the first chart. Missing data again!!!!

These "missing data results" were the same when plotting from either OnMarketData or OnBarUpdate.

Eventually found that this specific problem was related to how and when the chart updates.

By default, a chart with no indicators updates every time there is a price change.

If any indicator on the chart references Volume[0] in its calculations, NT now updates that chart when ever there is a change in Volume[0] as well as a change in price.

So if you are using just OnMarketData as your volume source, NT restricts that chart to price changes only.

If you scroll back up to the OnMarketData capture, you will see the following code.


double volume = Volume[0];


I have added this line of code to every one of my volume indicators so that they update more frequently and display all data correctly.



Finally, I posted NT7 versions of my released volume indicators yesterday in the elite download area.

They have all the updates talked about here.


Enjoy,


RJay


P.S. Special thanks to HNWtrader for posting the breakthrough code at the NT forum and to eDanny for helping test the new code against all NT chart types!!!


Last edited by RJay; December 17th, 2010 at 09:55 AM.
Reply With Quote
The following 11 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
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received


Greetings, and thanks for bringing this forward!

Just to clarify, (ie ForEx) if I am not using volume in my strategies, this is NOT something I need to adapt within my code?

Thanks,
Jon

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


Trader.Jon View Post
Greetings, and thanks for bringing this forward!

Just to clarify, (ie ForEx) if I am not using volume in my strategies, this is NOT something I need to adapt within my code?

Thanks,
Jon

This does not effect price based code.

Reply With Quote
The following 2 users say Thank You to RJay for this post:

Reply



futures io > > > > > Programming Indicators Using OnMarketData in NT7!!!

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
Visual Programming (programming without coding) LukeGeniol Platforms and Indicators 11 September 16th, 2016 01:49 PM
Problems Converting NT 6.5 indicators to NT7 Zondor NinjaTrader Programming 68 October 24th, 2014 08:07 AM
Imcompatable indicators NT7.04 jsengxx NinjaTrader Programming 14 March 18th, 2011 02:51 PM
BUG for OnMarketData timmyb NinjaTrader Programming 12 February 5th, 2011 10:32 PM
NT7 - Programming a Scale Justification=Overlay? chrisflow NinjaTrader Programming 3 May 27th, 2010 01:03 PM


All times are GMT -4. The time now is 02:50 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.08 seconds with 19 queries on phoenix via your IP 54.90.207.75