Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Referencing Close if CalculateOnBarClose set to false
Collapse
X
-
Referencing Close if CalculateOnBarClose set to false
if you have CalculateonBarClose set to false because you want somethings like entry orders to update on each tick, how would you go about referencing the close of a bar (for example) a five minute bar if you are running a strategy on a chart with time interval of 5 minutesTags: None
-
Hello fiddy,
Thank you for writing in.
What you could do is utilize the FirstTickOfBar property. What this does is check if the incoming tick that called OnBarUpdate() is the first tick of a new bar.
If this is the case, then print Close[1]. This will return the close value of the most recently closed bar.
Example:
More information about FirstTickOfBar can be found here: http://ninjatrader.com/support/helpG...ttickofbar.htmCode:// if the tick that called OnBarUpdate() is the first tick of a new bar, print the close value of the most recently closed bar if (FirstTickOfBar) Print(Close[1]);
Please, let us know if we may be of further assistance.Zachary G.NinjaTrader Customer Service
-
thanks
if you wanted to reference the open would you also be able to use open[1] in the same context
if (FirstTickOfBar)
{
open[1]
}
also if you wanted to reference two bars ago can you use Close[2] or does it not work like that? does this give two ticks ago result?
Comment
-
You sure about that?Originally posted by NinjaTrader_ZacharyG View PostClose[2] will provide the close value of the close bar two bars ago.
When COBC=false and FirstTickOfBar is true, you're saying that Close[2] is "close value of the close bar two bars ago"?
To the OP, try using Closes[0][2] to get the Close price of two bars ago.
See here:
Last edited by bltdavid; 04-06-2016, 10:54 AM.
Comment
-
Hello bltdavid,
Using ...
... with CalculateOnBarClose = false will print out the close value two bars ago.Code:if (FirstTickOfBar) Print(Close[2]);
Please take a look at this short demonstration video: http://screencast.com/t/SHHLzZfYbtaZachary G.NinjaTrader Customer Service
Comment
-
That's news to me.Originally posted by NinjaTrader_ZacharyG View PostHello bltdavid,
Using ...
... with CalculateOnBarClose = false will print out the close value two bars ago.Code:if (FirstTickOfBar) Print(Close[2]);
Please take a look at this short demonstration video: http://screencast.com/t/SHHLzZfYbta
The (very terse) documentation on FirstTickOfBar does not allude to this at all.
Can you attached your test script used in the video?
PS: See attached screenshot showing typo in NT8 documentation.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
560 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
325 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment