- Topics: 5
- Replies: 430
- Posts: 435
You could do this using the BARCOUNT() function set as a dynamic bar variable. The Bars= setting of the average would then reference this item, as per the following example…
$a = BARCOUNT() ;
V1 = MA(BARS=$a, CALC=Close) ;
In this script, the Moving Average is based on the number of bars the chart has available. We then see an average of all of the charts closing prices.
I use the Last() so that the value displays as a Horizontal Line on the chart (using a Show Plot).
The results will change based on the number of bars each chart has.
The average in this example is using a bar number of 6369.
You should be able to take this example and build on it for your required purposes.