H

#### horserider

##### Well-known member

**VIP**

**Warehouse**

Shows the deviation from the VWAP . Plot is aqua and VWAP is yellow.

Code:

```
#
# TD Ameritrade IP Company, Inc. (c) 2018-2019
#Original code TD Ameritrade IP Company, Inc. (c) 2018-2019 for Deviation Scaled Moving Average altered to be Deviation Scaled Moving Average #of VWAP by Horserider.
input length = 40;
def zeros = vwap -vwap[2];
def filter = reference EhlersSuperSmootherFilter(price = zeros, "cutoff length" = 0.5 * length);
def rms = Sqrt(Average(Sqr(filter), length));
def scaledFilter = filter / rms;
def alpha = 5 * AbsValue(scaledFilter) / length;
def deviationScaledMovAvg = CompoundValue(1, alpha * vwap + (1 - alpha) * deviationScaledMovAvg[1], vwap);
plot DSMA = deviationScaledMovAvg;
DSMA.SetDefaultColor(GetColor(1));
```

Last edited: