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
what "bar" am I on?
Collapse
X
-
what "bar" am I on?
how do I tell which "bar" I'm on, since "the beginning of time"... (Not referring to the "barsobject") (referring to the last bar on the right on the chart). I want to use that "bar" magnitude in my indicator. If there isn't any such thing, then, is there a way to detect when I've moved from the previous "bar" to the present (last on the right) bar? I'm not sure the "FirstTickOfBar" variable is always valid... an entire 5-minute bar could elapse with no tick in a thinly-traded market.Tags: None
-
Hello jalexan1,
Thanks for your post and welcome to the forums!
The bars are number from the beginning of the days back requested (or bars back) and will start at the first bar loaded, bar 0, progressing to the bar on the right end of the chart, incrementing the bar count. The integer CurrentBar will hold the bar number. reference: http://ninjatrader.com/support/helpG...currentbar.htm
When working with price data, such as High or Close you would provide a reference to the bar to use. To make things easy the concept is to use a "bars ago" reference. For example Close[0] refers to the current bar, Close[1] refers to the previous bar, Close[2] to the bar before that, etc. Reference:http://ninjatrader.com/support/helpG...rice_data2.htm
Note that the bars ago reference does change depending on the setting of CalculateOnBarClose. If set to true, [0] will point to the last completed bar on the right edge but not the current forming bar. If set to false, then [0] will point to the currently forming bar. Reference: http://ninjatrader.com/support/helpG...onbarclose.htm
With CalculateOnBarClose set to true, your code would execute once at the end of the bar.
With CalculateOnBarClose set to false, your code would execute on every incoming tick and in this mode FirstTickOfBar will be true on the very first tick of the newly forming bar. You are correct that in a thinly traded market it may take a while to get that first tick but it will still trigger FirstTickOfBar. Reference: http://ninjatrader.com/support/helpG...ttickofbar.htmPaul H.NinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by volIQ, 03-27-2024, 04:28 PM
|
3 responses
21 views
0 likes
|
Last Post
by RJay
Today, 05:41 AM
|
||
Started by Nickgiaco, 02-26-2024, 10:23 AM
|
2 responses
72 views
0 likes
|
Last Post Today, 05:12 AM | ||
Started by Johndc, Today, 04:39 AM
|
0 responses
4 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
9 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
13 views
0 likes
|
Last Post Today, 02:00 AM |
Comment