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
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:
Code:// 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
-
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 ...
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
-
Originally posted by NinjaTrader_ZacharyG View PostHello bltdavid,
Using ...
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 timmbbo, Today, 08:59 AM
|
0 responses
1 view
0 likes
|
Last Post
by timmbbo
Today, 08:59 AM
|
||
Started by bmartz, 03-12-2024, 06:12 AM
|
5 responses
33 views
0 likes
|
Last Post Today, 08:34 AM | ||
Started by Aviram Y, Today, 05:29 AM
|
4 responses
14 views
0 likes
|
Last Post
by Aviram Y
Today, 07:57 AM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
3 responses
28 views
0 likes
|
Last Post Today, 07:41 AM | ||
Is it possible to have a drawing, such as a line, cycle through different colors?
by gentlebenthebear
Started by gentlebenthebear, Today, 01:30 AM
|
1 response
8 views
0 likes
|
Last Post Today, 07:30 AM |
Comment