Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Programming Indicators Using OnMarketData in NT7!!!
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.
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!!!