int daysBackStart = 7; int daysBackFinish = 3; DateTime today = DateTime.Now; DateTime beginDay = today.AddDays(-1*daysBackStart); DateTime endDay = today.AddDays(-1*daysBackFinish); // OnBarUpdate int startBar = CurrentBar - Bars.GetBar(beginDay); int endBar = CurrentBar - Bars.GetBar(endDay); int fromBar = startBar+10; double myMax = MAX(High,10)[fromBar]; // if fromBar < 0 i have exception "needed to be between 0 and 34100 but was -47 error."
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
MAX problem
Collapse
X
-
MAX problem
Hello i'm check my indicator on HISTORY and i got the problem with MAX().
Code:Last edited by nordseven; 01-31-2017, 07:28 AM.Tags: None
-
Hello Nordseven,
Thank you for your note.
Passing a negative index in NT7 worked but was not supported. In NT8 it neither works nor is supported. A negative index value only works historically and never in live data.
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
-
Hello Nordseven,
Passing a negative value as a bar index in NT8 is not supported.
I would suggest checking to make sure the bar index value is not negative.
So prior to,
double myMax = MAX(High,10)[fromBar];
You could add,
if(fromBar<0) return;
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Tim-c, Today, 08:36 AM
|
1 response
2 views
0 likes
|
Last Post Today, 08:45 AM | ||
Started by goodknight777, Today, 08:43 AM
|
0 responses
2 views
0 likes
|
Last Post Today, 08:43 AM | ||
Started by martini, Yesterday, 04:45 PM
|
3 responses
27 views
0 likes
|
Last Post Today, 08:38 AM | ||
Started by Mestor, Today, 03:15 AM
|
2 responses
10 views
0 likes
|
Last Post
by Mestor
Today, 08:36 AM
|
||
Started by roblogic, 11-30-2023, 06:20 PM
|
57 responses
1,364 views
0 likes
|
Last Post
by playr101
Today, 08:35 AM
|
Comment