amirfutures
New member
The formula of Moving Average Triangular is:
input price = close;
input length = 9;
input displace = 0;
def effectiveLength = Ceil((length + 1) / 2);
plot AvgTri = Average(Average(price[-displace], effectiveLength), effectiveLength);
##########################################################################################
I would like to replace the "Average" function with an average that is calculated with Fold function, as follows:
input price = close;
input length = 9;
plot SMA = (fold n = 0 to length with s do s + getValue(price, n, length - 1)) / length;
The end result should look like:
input price = close;
input length = 9;
input displace = 0;
def effectiveLength = Ceil((length + 1) / 2);
plot AvgTri = SMA(SMA(price[-displace], effectiveLength), effectiveLength);
Thanks
input price = close;
input length = 9;
input displace = 0;
def effectiveLength = Ceil((length + 1) / 2);
plot AvgTri = Average(Average(price[-displace], effectiveLength), effectiveLength);
##########################################################################################
I would like to replace the "Average" function with an average that is calculated with Fold function, as follows:
input price = close;
input length = 9;
plot SMA = (fold n = 0 to length with s do s + getValue(price, n, length - 1)) / length;
The end result should look like:
input price = close;
input length = 9;
input displace = 0;
def effectiveLength = Ceil((length + 1) / 2);
plot AvgTri = SMA(SMA(price[-displace], effectiveLength), effectiveLength);
Thanks