MorayTheEel
New member
TradingView's RMA function is the Wilder's Moving Average in every other platform. This is basically two Keltner Channels using Wilder's instead of the standard EMA.
Enjoy!
Code:
script nz {
input data = close;
input repl = 0;
def ret_val = if data!=0 then data else repl;
plot return = ret_val;
}
input scl_t = 10;
input mcl_t = 30;
input scm = 1.0;
input mcm = 3.0;
input src = close;
input showCloud = yes;
def scl = scl_t / 2;
def mcl = mcl_t / 2;
def ma_scl = MovingAverage(AverageType.WILDERS, src, scl);
def ma_mcl = MovingAverage(AverageType.WILDERS, src, mcl);
def scm_off = scm * ATR(scl);
def mcm_off = mcm * ATR(mcl);
def scl_2 = scl / 2;
def mcl_2 = mcl / 2;
plot sct = nz(ma_scl[scl_2], src)+ scm_off;
plot scb = nz(ma_scl[scl_2], src)- scm_off;
plot scmid = (sct + scb) / 2;
plot mct = nz(ma_mcl[mcl_2], src)+ mcm_off;
plot mcb = nz(ma_mcl[mcl_2], src)- mcm_off;
plot mcmid = (mct + mcb) / 2;
scmid.SetDefaultColor(Color.GRAY);
mcmid.SetDefaultColor(Color.BLACK);
sct.SetDefaultColor(Color.DOWNTiCK);
scb.SetDefaultColor(Color.DOWNTiCK);
mct.SetDefaultColor(Color.UPTiCK);
mcb.SetDefaultColor(Color.UPTiCK);
AddCloud(if showCloud then sct else Double.NaN, scb, Color.DOWNTICK, Color.DOWNTICK);
AddCloud(if showCloud then mct else Double.NaN, mcb, Color.UPTICK, Color.UPTICK);
Enjoy!