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 CarlTrading, 03-31-2026, 09:41 PM
|
1 response
82 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
43 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
64 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
68 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
56 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment