if (IsFirstTickOfBar)
{
myDataSerie[0] = myDataSerie[1];
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
IsFirstTickOfBar and Series<T> Problem
Collapse
X
-
IsFirstTickOfBar and Series<T> Problem
Hi, i have the problem that with fast market movements like news etc. my Series<T> are not taken over from one bar to the next. Can it be that e.g. with range bars no ticks are in a bar, and it therefore comes to problems?
I take the values from the previous bar at the first tick of each new bar and use them to form my series. It happens that with fast moves (news), my series restarts because there is no data in the previous bar. How can I solve this most effectively, anyone has an idea?Code: -
Maybe try this,
The idea is, if the previous bar has volume > 0, then presumablyCode:if (IsFirstTickOfBar) { myDataSerie[0] = Volume[1] > 0 ? myDataSerie[1] : 0; }
you have a valid value in your myDataSeries[1] -- otherwise there
is zero volume in the previous bar and you use zero.
-
Hello sidlercom80,
Thanks for your post.
bltdavid is correct. You could create a condition checking if the volume of the previous bar (Volume[1]) is greater than 0. Then, you could assign myDataSeres[1] to myDataSeries[0].
See this help guide page for more information about Volume[]: https://ninjatrader.com/support/help...ies_volume.htm
Let me know if I may assist further.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
Hi bltdavid and BrandonH, thanks for your posts. I can not use a value of 0, because otherwise my series would be interrupted and thus unusable. If I checked e.g. at the previous bar for volume and there is no volume, I would have to go back one bar further and check there for volume....To stay with your example with the volume, I add the volume bar by bar. So if now in a bar no volume is present, because no data is available, I can not use 0 for the next bar, because then the new bar would start again with a volume of 0.Originally posted by bltdavid View PostMaybe try this,
The idea is, if the previous bar has volume > 0, then presumablyCode:if (IsFirstTickOfBar) { myDataSerie[0] = Volume[1] > 0 ? myDataSerie[1] : 0; }​
you have a valid value in your myDataSeries[1] -- otherwise there
is zero volume in the previous bar and you use zero.
I would have to use something like this:
The question is, is there a better way to do this?Code:if (IsFirstTickOfBar) { myDataSerie[0] = Volume[1] > 0 ? myDataSerie[1] : myDataSerie[2]; }
Comment
-
Hello sidlercom80,
Thanks for your note.
This would be the best way to go about accomplishing your goal. You would check if the previous bar's Volume[1] is greater than 0 and set your myDataSerie variable.
Let me know if I may assist further.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
581 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
338 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment