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 futtrader, 04-21-2024, 01:50 AM
|
4 responses
41 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
11 views
0 likes
|
Last Post
by bltdavid
Today, 02:44 PM
|
||
Started by port119, Today, 02:43 PM
|
0 responses
7 views
0 likes
|
Last Post
by port119
Today, 02:43 PM
|
||
Started by Philippe56140, Today, 02:35 PM
|
0 responses
7 views
0 likes
|
Last Post Today, 02:35 PM | ||
Started by 00nevest, Today, 02:27 PM
|
0 responses
7 views
0 likes
|
Last Post
by 00nevest
Today, 02:27 PM
|
Comment