Thanks to RJay and eDanny for adding their contributions here. It gave me a better understanding of what is going on.
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
Last/First tick of volume bar changed in V7
Collapse
X
-
Originally posted by NinjaTrader_Josh View Post
Thanks to RJay and eDanny for adding their contributions here. It gave me a better understanding of what is going on.
-
Possible solution- Is it reliable?
Given that FirstTickOfBar cannot be used in OnMarketData, I looked for an alternative. I don't know if it is universally valid, but it seems to be a simple fix for my indicator, at least for the chart types and parameters I use. Since every tick triggers OnMarketData at some point, and NT has a Bars.TickCount (hoping of course that NT is updating Bars.TickCount before OnMarketData gets triggered; it appears to be working that way), I have replacedCode:if (FirstTickOfBar)
Code:if (Bars.TickCount == 1)
This may be an imperfect substitute for a true first tick of bar indicator (OR could this be it?) that will work in OnMarketData, but for the times of day and bar intervals that are of interest to me, it seems to be working well so far. Does anyone see a problem with this?Last edited by HNWtrader; 12-10-2010, 03:06 PM.
Comment
-
if(BarID != CurrentBar)
{
bidsumUp = 0;
asksumUp = 0;
totalaskvol = 0;
totalbidvol = 0;
BarID = CurrentBar;
}
Comment
-
Originally posted by rt6176 View Postif(BarID != CurrentBar)
{
bidsumUp = 0;
asksumUp = 0;
totalaskvol = 0;
totalbidvol = 0;
BarID = CurrentBar;
}
A number representing the current bar in a Bars object that the OnBarUpdate() method in an indicator or strategy is currently processing. For example, if a chart has 100 bars of data, the very first bar of the chart (left most bar) will be number 0 (zero) and each subsequent bar from left to right is incremented by 1.
In some of the posts that you linked you talk about having to save the previous tick values to be processed later. I don't know if you still have to do that, but I don't think there is any need to do it with "if (Bars.TickCount == 1)" because it gets me directly to the first tick of the bar for processing, perhaps even before the bar appears on the chart. I have no idea what NT7 will do if there is a bar with only one tick, but I am never interested in such events.
What I did was to change my test indicator to read Volume[0] in OnBarUpdate, and OnMarketdata. They are indeed not the same, with the reading from OnMarketData leading the reading from OnBarUpdate by 1 tick in NT7.
I looked at this
Code:protected override void OnBarUpdate() { barVolumeBarOld = barVolumeBar; barVolumeBar = (long) Volume[0]; } protected override void OnMarketData(MarketDataEventArgs e) { if (e.MarketDataType == MarketDataType.Ask) { askPrice = e.Price; return; } else if (e.MarketDataType == MarketDataType.Bid) { bidPrice = e.Price; return; } else if (e.MarketDataType != MarketDataType.Last || ChartControl == null || askPrice == 0 || bidPrice == 0) return; barVolumeDataOld = barVolumeData; barVolumeData = (long) Volume[0]; volume = e.Volume; price = e.Price; count += 1; if (count < 3) Print ("("+Bars.Period+") " + price + " " + volume + " " + barVolumeBarOld + " " + barVolumeBar + " " + barVolumeDataOld + " " + barVolumeData + " count " + count + " TickCount " + Bars.TickCount); if(FirstTickOfBar) { count = 0; Print (""); Print ("("+Bars.Period+") " + price + " " + volume + " " + barVolumeBarOld + " " + barVolumeBar + " " + barVolumeDataOld + " " + barVolumeData + " count " + count + " TickCount " + Bars.TickCount); } }
Thanks again for your input.Last edited by HNWtrader; 12-11-2010, 10:19 AM.
Comment
-
HNWtrader,
I do not foresee issues with your approach at this point in time except the missing Bars null reference check you should be using when utilizing Bars.TickCount.
Please be sure to check if (Bars != null) before accessing Bars.TickCount outside of OnBarUpdate().Josh P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by kaywai, 09-01-2023, 08:44 PM
|
5 responses
601 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by xiinteractive, 04-09-2024, 08:08 AM
|
6 responses
22 views
0 likes
|
Last Post Today, 12:31 AM | ||
Started by Pattontje, Yesterday, 02:10 PM
|
2 responses
17 views
0 likes
|
Last Post
by Pattontje
Yesterday, 11:49 PM
|
||
Started by flybuzz, 04-21-2024, 04:07 PM
|
17 responses
230 views
0 likes
|
Last Post
by TradingLoss
Yesterday, 11:45 PM
|
||
Started by agclub, 04-21-2024, 08:57 PM
|
3 responses
17 views
0 likes
|
Last Post
by TradingLoss
Yesterday, 11:42 PM
|
Comment