I'm using NT 6.5
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to know when a bar closes when CalculateOnBarClose=false
Collapse
X
-
How to know when a bar closes when CalculateOnBarClose=false
If I have a strategy the has CalculateOnBarClose = false because I want to get OnBarUpdate() events for each tick, but I also want to make some decisions based on how a bar closes. So how can I determine when a bar closes when I have CalculateOnBarClose = false?
I'm using NT 6.5Tags: None
-
Hello Shodson,
The opening of the next bar is the same event as the closing of the prior bar. You can use FirstTickOfBar to identify this. The reference sample below can help implementing this.
Separating logic to either calculate once on bar close or on every tickRyan M.NinjaTrader Customer Service
-
Thanks, I have a follow-up
If I am using multiple time frames, and my primary time frame is 15min and my secondary time frame is 1min then my OnBarUpdate() will be called 16 times: 15 times for BarsInProgress 1 and once for BarsInProgress 0, even if I have CalculateOnBarClose set to true, correct?Last edited by shodson; 06-29-2010, 10:33 AM.
Comment
-
Hello Shodson,
I'm not sure the exact number of calls done. I suggest adding a counter if you would like to track this. When using CalculateOnBarClose == true, OnBarUpdate is called only once per bar. When set to false it will update for each incoming tick.
The reference sample below is good for understanding the sequence of OnBarUpdate() calls in a multi time frame strategy:
Backtesting NinjaScript Strategies with an intrabar granularity
Excerpted below:
When working with multiple bar series objects it is important to understand the sequential order in which the OnBarUpdate() method is triggered. The bars will always run with the primary first followed by the secondary and so on.
Important: Primary bars will always execute before the secondary bar series.
If a bar is timestamped as 12:00PM on the 5min bar series, the call order between the equally timestamped 12:00PM bar on the 1min bar series is like this:
12:00PM 5min
12:00PM 1min
12:01PM 1min
12:02PM 1min
12:03PM 1min
12:04PM 1min
12:05PM 5min
12:05PM 1minRyan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by lightsun47, Today, 03:51 PM
|
0 responses
4 views
0 likes
|
Last Post
by lightsun47
Today, 03:51 PM
|
||
Started by 00nevest, Today, 02:27 PM
|
1 response
8 views
0 likes
|
Last Post
by 00nevest
Today, 03:48 PM
|
||
Started by futtrader, 04-21-2024, 01:50 AM
|
4 responses
44 views
0 likes
|
Last Post
by futtrader
Today, 03:01 PM
|
||
Can someone turn this thinkscript into a ninjascript. 5PM CST OHL and Previous Day
by Option Whisperer
Started by Option Whisperer, Today, 09:55 AM
|
1 response
13 views
0 likes
|
Last Post
by bltdavid
Today, 02:44 PM
|
||
Started by port119, Today, 02:43 PM
|
0 responses
8 views
0 likes
|
Last Post
by port119
Today, 02:43 PM
|
Comment