germanburrito
Active member
These clouds consist of a deviation scaled sma, as well as a vwap scaled sma, these clouds may act as support and resistance because of the nature of being weighted by volume and standard deviation of set period, when the bands squeeze it may indicate a reversal or a weakening trend, when the bands expand the opposite is true.
Code:
# Nube 6.24.19
# German_burrito
input length = 24;
input price = vwap;
input length2 = 34;
def p = if IsNaN(price) then p[1] else price;
def v = if IsNaN(volume) then v[1] else volume;
def zeros = close - close[2];
def filter = reference EhlersSuperSmootherFilter(price = zeros, "cutoff length" = 0.5 * length2);
def rms = Sqrt(Average(Sqr(filter), length2));
def scaledFilter = filter / rms;
def alpha = 5 * AbsValue(scaledFilter) / length2;
def deviationScaledMovAvg = CompoundValue(1, alpha * close + (1 - alpha) * deviationScaledMovAvg[1], close);
plot DSMA = deviationScaledMovAvg;
DSMA.SetDefaultColor(GetColor(1));
plot VWAP = if IsNaN(price) then Double.NaN else
Sum(p * v, length) / Sum(v, length);
addCloud(dsma, vwap, color.green, color.red);
dsma.AssignValueColor(if dsma > vwap
then color.green
else color.red);
vwap.AssignValueColor(if dsma > vwap
then color.green
else color.red);
Last edited: