Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
DaysToLoad
Collapse
X
-
Tags: None
-
Won't work how?Originally posted by Danville.Sumobay View PostI need the equivalent of "Bars.BarsData.DaysBack" from NT7 to NT8
I tried DaysBack from the help guide but it won't work.
ChartBars.DaysBack doesn't work?
Can you post your code?
-
I got an error when added that to my script.
'NinjaTrader.Gui.Chart.ChartBars' does not contain a definition for 'DaysBack' and no extension method 'DaysBack' accepting a first argument of type 'NinjaTrader.Gui.Chart.ChartBars' could be found (are you missing a using directive or an assembly reference?)
Thanks
Comment
-
Thank you for your response,
I simply add this line for NT8
int d = ChartBars.DaysBack; //this produce an error
While I had no problem this equivalent in NT7 with the following
int d = Bars.BarsData.DaysBack;
Comment
-
Hello Danville.Sumobay,
Thank you for your reply.
We need a little more context here. Where in your code does this occur? Is this inside OnBarUpdate()? Elsewhere? If you could provide a larger code sample that would be helpful in discerning the context.
Thanks in advance; I look forward to assisting you further.
Comment
-
Yes, it is inside the OnBarUpdate()
protected override void OnBarUpdate()
{
if (BarsArray[0].BarsType.IsRemoveLastBarSupported)
{
if (CurrentBar == 0)
Value[0] = Input[0];
else
{
double last = Value[1] * Math.Min(CurrentBar, Period);
if (CurrentBar >= Period)
Value[0] = (last + Input[0] - Input[Period]) / Math.Min(CurrentBar, Period);
else
Value[0] = ((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));
}
}
else
{
if (IsFirstTickOfBar)
priorSum = sum;
sum = priorSum + Input[0] - (CurrentBar >= Period ? Input[Period] : 0);
Value[0] = sum / (CurrentBar < Period ? CurrentBar + 1 : Period);
}
int d = ChartBars.DaysBack;
Print("DaysToLoad: "+d);
}
I saw "DaysBack" on the documentation but I don't know how to apply.
Thanks
Comment
-
Hello Danville.Sumobay,
Thank you for your reply.
You're trying to use ChartBars.DaysBack, but the correct syntax here for that would be ChartBars.Properties.DaysBack.
One note: I would recommend using full brackets with your if/else statements, like this:
if (some condition)
{
// do something
}
else
{
// do something else
}
This will help better structure your code. You can omit brackets if it's just one line after the if statement, as in:
if (CurrentBar < Period)
return;
Otherwise, I recommend using both opening and closing brackets, otherwise things can get confusing quickly.
Please let us know if we may be of further assistance to you.
Comment
-
Really? That simple, huh?Originally posted by NinjaTrader_Kate View Postthe correct syntax here for that would be ChartBars.Properties.DaysBack.
Gee, hard to know that, since the documentation does not have a SINGLE example of the usage.
I had even grepped every NT8 indicator, searching for an example of DaysBack ... no joy.
When you add up all the time wasted for every person affected because of insufficient documentation, it boggles the mind.
Unfortunately, there is still no substitute for live and learn.

- Likes 1
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
574 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment