Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Total Volume current and prior day
Collapse
X
-
Hello Mike.A,
Thank you for your reply.
Now that your script is looking for the values from up to 3 bars ago, you will need to adjust your CurrentBars check. Here is what you currently have:
if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
return;
Since you are wanting to check a value from Closes[1])[3] then you will need to make sure that there are at least 3 bars on the chart before this is calculated. We have a page about making sure you have enough bars here:
If you adjust the statement to the following, I suspect it should resolve the error:
if (CurrentBars[0] < 3 || CurrentBars[1] < 3)
return;
Please let us know if we may be of further assistance.
Comment
-
Hello Mike,
If you change a barsAgo reference from 0 to 1, you would be changing from "the current processing bar" to "the previous bar."
Similarly, changing a barsAgo reference from 1 to 2, you would be changing from "the previous bar" to "2 bars ago"
When scripts start processing, they start on bar 0, then process bar 1, bar 2, etc.
If we reference 1 bar ago on bar 0, that "1 bar ago" is not yet available to the script because it has not been processed yet.
So you need to make sure that if the script is processing before bar 2, it is not referencing 2 bars ago.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CaptainJack, 05-29-2026, 05:09 AM
|
0 responses
240 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 05:09 AM
|
||
|
Started by CaptainJack, 05-29-2026, 12:02 AM
|
0 responses
157 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 12:02 AM
|
||
|
Started by charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
165 views
1 like
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
248 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
199 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|

Comment