Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Display average indicator output looking back x bars.
Collapse
X
-
Display average indicator output looking back x bars.
Is there any way to get an indicator to display the average output value looking back x bars? For example if I took the SMA and wanted to display it as a horizontal line that updated it's value every week instead of updating with each bar and displaying the average over x bars looking back. Is this possible in the Ninjascript Editor using Ninjatrader 8? Any tips on how I could accomplish this? ThanksTags: None
-
Hi jerblaster23, thanks for your question.
There could be a number of ways to do this. In NinjaScript you can make multi time frame scripts. So you run the script on the primary data series and the script will also have the added data series added with the AddDataSeries() method. We have a guide on multi time frame an instrument scripts here:
https://ninjatrader.com/support/help...nstruments.htm
The idea here is to add the larger time period and gather data from each bar close of that series e.g.
if(BarsInProgress == 1) //secondary series OnBarUpdate() call
{
double value = SMA(Highs[1], 20)[0];
double value1 = SMA(Closes[1], 20)[0];
}
Please let me know if I can assist any further.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
333 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment