or to be more specific: How can I get the daily highs and lows of yesterday, 2 days before, etc within a strategy script where I use range bars ?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Get daily highs and lows
Collapse
X
-
-
Hello rafe0304,
Thanks for your post.
One way to get the high and low of the previous days would be the use of the GetDayBar() method that will create daily bars from your data and make the OHLC values available.
Syntax:
Bars.GetDayBar(int tradingDaysBack).High
Bars.GetDayBar(int tradingDaysBack).Low
Please see: http://ninjatrader.com/support/helpG...?getdaybar.htmPaul H.NinjaTrader Customer Service
-
Hello rafe0304,
Thanks for your post.
Using the GetDayBar would require that you have the data loaded before trying to access it. Keep in mind that it makes up a day bar from your exiting data bars. So if you are looking back 1 day you would need 1 day plus the current days data loaded before accessing. You can accomplish this by doing a CurrentBar check (which could be lengthy in this application) or test for null bars first and then access when not null.
Example:
if ( Bars.GetDayBar(1) != null)
{
yesterdaysHigh = Bars.GetDayBar(1).High;
}Paul H.NinjaTrader Customer Service
Comment
-
Hello rafe0304,
Thanks for your reply.
"So if you are looking back 1 day you would need 1 day plus the current days data loaded before accessing. You can accomplish this by doing a CurrentBar check".
Reference: http://ninjatrader.com/support/helpG...currentbar.htmPaul H.NinjaTrader Customer Service
Comment
-
Can I do that check based on days? If I work with range bars, I got a changing number of bars each day such that I cannot convert the number of days I need in a number of bars.
So how can I load the necessary number of historic days when I need it in my strategy?
Comment
-
Hello rafe0304,
Thanks for your reply.
Next option would be to add daily bars to your strategy.
Please see: http://ninjatrader.com/support/helpGuides/nt7/?add3.htm
and
http://ninjatrader.com/support/helpG...nstruments.htmPaul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
26 views
0 likes
|
Last Post
by wzgy0920
Today, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Today, 10:33 PM
|
||
Started by wzgy0920, Yesterday, 09:53 PM
|
2 responses
49 views
0 likes
|
Last Post
by wzgy0920
Today, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
192 views
0 likes
|
Last Post
by Hasadafa
Today, 10:19 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,234 views
0 likes
|
Last Post Today, 08:07 PM |
Comment