I'm utilizing the IsFirstTickOfBar property with the calculate mode set to OnPriceChange. When debugging this behaviour I see that the first tick is actualy the first tick after the middle of the bar (blue arrow) which is odd because based on the bar index it should be at the red arrow. Is this an error or do I misinterpret?
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
First tick of bar
Collapse
X
-
First tick of bar
Hi guys
I'm utilizing the IsFirstTickOfBar property with the calculate mode set to OnPriceChange. When debugging this behaviour I see that the first tick is actualy the first tick after the middle of the bar (blue arrow) which is odd because based on the bar index it should be at the red arrow. Is this an error or do I misinterpret?
Tags: None
-
Hello Vanderbeke,
Thank you for your note.
The chart does not have a price axis, time duration or instrument so its not possible to debug this based on the information provided.
Would you please provide detailed steps on how to test the behavior?
Also please include the version of NinjaTrader you're using. For example 8.0.12.2 64-bit.
I look forward to your reply.Alan P.NinjaTrader Customer Service
-
Hello Vanderbeke,
Thank you for your note.
Without the full code we're unable to test on our end.
If you'd like to upload the full code I can take a look and see if anything jumps out. Or if you'd prefer to email a copy, send to platformsupport[at]ninjatrader[dot]com with Attn: Alan P in the Subject line. Also within the email please include a link to this thread, and the files.
I look forward to your reply.Alan P.NinjaTrader Customer Service
Comment
-
Hi Alan
It's pretty straight forward. If you look at the output or put your debugger on it you will see that the FirstTickOfBar actualy refers to the first bar with a time greater than that of the previous bar. In this case it looks at the time of the 377 tick bar and then to determine the first tick it looks at the first 1 tick bar with a time greater than the 377 tick bar which isn't correct.
Code:protected override void OnStateChange() { if (base.State == State.SetDefaults) { base.Calculate = Calculate.OnPriceChange; base.IsUnmanaged = true; } else if (base.State == State.Configure) { AddDataSeries(BarsPeriodType.Tick, 1); } } protected override void OnBarUpdate() { if (CurrentBar < this.ATRSlow) return; if (BarsInProgress == 0) { if (IsFirstTickOfBar) { Print(string.Format("Bar index: {0}; Time: {1}; O: {2}; H: {3};L: {4}; C: {5}", CurrentBar, Bars.GetTime(CurrentBar), Open[0], High[0], Low[0], Close[0])); } } else if (BarsInProgress == 1) { Print(string.Format("Bar index: {0}; Time: {1}; O: {2}; H: {3};L: {4}; C: {5}", CurrentBar, Bars.GetTime(CurrentBar), Open[0], High[0], Low[0], Close[0])); } }
Comment
-
Hi Alan
I just notice that when I open a chart with on top 377 tick bars and below 1 tick bars that the bar index of the above charts switches to 1 on bar 565 of the 1 tick chart. Is there a reason this is the case and not 377?
Comment
-
Hello Vanderbeke,
I'm replying on behalf of Alan who is out of the office today.
CurrentBar will represent the bar index of the iterating data series. For BarsInProgress 0, you will print the bar index for the primary data series. CurrentBar on BarsInProgress 1 will represent the bar index of the 1 tick data series that is added to the script.
Adding a 1 tick data series to a chart that is identical to the added data series will change the indexes of that data series if there is more data requested by the chart.
I have attached a demonstration explaining further - https://drive.google.com/file/d/1xZ0...w?usp=drivesdk
Please let us know if you have any additional questions.JimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
5 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
12 views
0 likes
|
Last Post Today, 02:00 AM | ||
Started by Mariawilcoxi, Today, 01:32 AM
|
0 responses
4 views
0 likes
|
Last Post
by Mariawilcoxi
Today, 01:32 AM
|
||
Started by gleichnerany, Today, 01:17 AM
|
0 responses
5 views
0 likes
|
Last Post
by gleichnerany
Today, 01:17 AM
|
||
Started by WHICKED, 03-27-2024, 12:33 PM
|
4 responses
46 views
0 likes
|
Last Post Today, 12:28 AM |
Comment