Enhanced Standard Deviation Bands

Chuck

Moderator
Staff member
rOFGpZZ.png
The Exponential Standard Deviation (ESD) Bands are a volatility-band technical indicator proposed by Vitali Apirine. This indicator comprises two lines (bands) plotted, by default, two exponential standard deviations above and below an exponential moving average. The exponential standard deviation is equal to the root mean square of price deviations from its exponential moving average.

The interpretation of ESD Bands involves several techniques:

  • Volatility analysis. In ESD Bands, the concept of volatility is based on the exponential standard deviation: the higher the volatility, the greater the deviation. Thus, the distance between the bands increases when the volatility level rises. Conversely, when the volatility decreases, the bands converge.
  • Trend analysis. ESD Bands are trend-following and lag price action as the exponential moving average is used in the calculation. The bands tend to move upward in uptrends and downward in downtrends. In sideways trends, the bands move horizontally.
  • Trend reversal detection. The distance between the bands is generally substantial to keep the price plot inside. However, the price may be sometimes seen pierce either band indicating a possible trend reversal or emergence. When the bands move upward and the price rises above the upper band, the start of an uptrend is possible. Piercing the lower band when the bands are in downturn might signify the start of a downtrend.
  • Sideways trend analysis. When the trend is flat and the bands move in the horizontal direction, the price can be often seen form a peak at the upper band and a trough at the lower one.


Code:
# Enhanced Standard Deviation Bands by Horserider 9/21/2019
# Two standard TD Ameritrade IP Company, Inc. (c) 2019 StandardDeviation studies      combined into one study with deviations being 1.3 and 2.0 . User changeable length, dev, and avg type to suit their trading.
#
# Inner bands
input length = 10;#20
input numDevDn = -1.3;
input numDevUp = 1.3;
input averageType = AverageType.EXPONENTIAL;

def avg = MovingAverage(averageType, close);
def expDev = ExpAverage(AbsValue(avg - close), length);

plot UpperBand = avg + numDevUp * expDev;
plot MidLine = avg;
plot LowerBand = avg + numDevDn * expDev;

UpperBand.SetDefaultColor(GetColor(1));
MidLine.SetDefaultColor(GetColor(1));
MidLine.SetStyle(Curve.SHORT_DASH);
LowerBand.SetDefaultColor(GetColor(1));

# Outer bands
input lengthob = 10;#20
input numDevDnob = -1.5;#-2.0
input numDevUpob = 1.5;#2.0
input averageTypeob = AverageType.EXPONENTIAL;

def avgob = MovingAverage(averageTypeob, close);
def expDevob = ExpAverage(AbsValue(avgob - close), lengthob);

plot UpperBandob = avgob + numDevUpob * expDevob;
#plot MidLineob = avgob;
plot LowerBandob = avgob + numDevDnob * expDevob;

UpperBandob.SetDefaultColor(GetColor(1));
#MidLineob.SetDefaultColor(GetColor(1));
#MidLineob.SetStyle(Curve.SHORT_DASH);
LowerBandob.SetDefaultColor(GetColor(1));


# Clouds for safe zones Light gray for long, dark gray for short.
AddCloud (midline,upperbandob, Color.lIGHT_GRAY, Color.lIGHT_GRAY);
AddCloud(midline, lowerband, Color.GRAY, Color.GRAY);

# Clounds for areas of possible reversals. Green for longs, red for shorts.
AddCloud( upperband,upperbandob, Color.LIGHT_RED, Color.LIGHT_RED);
AddCloud( lowerband,lowerbandob, Color.LIGHT_GREEN, Color.LIGHT_GREEN);

# Plot arrows for close crosses of Deviation lines. Indside plum, Outside red/green Arrows included because many like arrows. I suggest being careful following any arrow signal.
plot UpSignalob =  close crosses below   lowerbandob ;
plot DownSignalob = close crosses above upperbandob;

plot UpSignal =  close crosses   lowerband ;
plot DownSignal = close crosses  upperband;

UpSignal.SetDefaultColor(Color.PLUM);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.PLUM);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

UpSignalob.SetDefaultColor(Color.UPTICK);
UpSignalob.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignalob.SetDefaultColor(Color.DOWNTICK);
DownSignalob.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
Last edited:
Top