Say I want the average closing price of the last 20 bars, is there any easier way to do it than (Close[0] + Close[1] + ... + Close[19]) / 20?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Calculating the average of previous bars.
Collapse
X
-
Calculating the average of previous bars.
Is there an easy way to calculate the average of N previous bars in a series?
Say I want the average closing price of the last 20 bars, is there any easier way to do it than (Close[0] + Close[1] + ... + Close[19]) / 20?Tags: None
-
Okay sure but what about the median instead of the average? Regarding the average, I was hoping for something like Average(Close, 20) but if the way to do that in a strategy is to use SMA(Close, 20), I'm guessing there isn't a "Simple Moving Median" indicator? Is there?
Comment
-
Hi rcloutier, thanks for your reply.
There is not an indicator but there is a Median price series that you can reference:
https://ninjatrader.com/support/help...t8/?median.htm
You will access this series just like you would the Close, Open, High, Low series e.g. Median[0]
Please let me know if I can assist any further.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CaptainJack, 05-29-2026, 05:09 AM
|
0 responses
476 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 05:09 AM
|
||
|
Started by CaptainJack, 05-29-2026, 12:02 AM
|
0 responses
317 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
254 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
340 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
306 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|

Comment