TradingView
TradeStation
2020年3月18日下午12點36分

Overbought or Oversold? Check Distance From MA 

S&P 500SP

描述

Moving averages are one of the most basic tools for technical analysts. They can be useful for both trend analysis and for mean reversion.

But how can you know when price is historically overbought or oversold relative to a moving average? Distance from MA can help.

This indicator calculates the distance from a moving average as a percentage and plots the result as an oscillator. Values above 0 appear in green, while negative readings are colored red.

This chart highlights the depth of the S&P 500's recent selloff. As you can see, the close dipped to 25 percent below its 50-day SMA on Monday. That was its most oversold condition since November 20, 2008 -- in the middle of the subprime financial crisis.

Distance from MA can handle five types of moving average. Simply change the "AvgType" input according to this key:

1 - Simple Moving Average

2 - Exponential Moving Average

3 - Hull Moving Average

4 - Weighted Moving Average

5 - Volume-Weighted Moving Average
評論
juanman.gd
Very good analysis , thanks for sharing
Ungovernable
Added custom timeframe feature -
//@version=4
//MA Distance plots the price's distance from a given MA in percent. It's color coded green (positive) or red (negative).

//MA types are:
// 1 - simple
// 2 - exponential
// 3 - Hull
// 4 - weighted
// 5 - volume weighted

study(title = "Distance from MA", shorttitle="MA_dist")
timeframeInput = input(title="Timeframe", type=input.resolution, defval="")
length = input(50, minval=1, title="Length")
src = input(close, title="Source")
matype = input(1, minval=1, maxval=5, title="AvgType")

simplema = security(syminfo.tickerid, timeframeInput, sma(src,length))
exponentialma = security(syminfo.tickerid, timeframeInput, ema(src,length))
hullma = security(syminfo.tickerid, timeframeInput, wma(2*wma(src, length/2)-wma(src, length), round(sqrt(length))))
weightedma = security(syminfo.tickerid, timeframeInput, wma(src, length))
volweightedma = security(syminfo.tickerid, timeframeInput, vwma(src, length))

avgval = matype==1 ? simplema : matype==2 ? exponentialma : matype==3 ? hullma : matype==4 ? weightedma : matype==5 ? volweightedma : na

distance=((close/avgval)-1)*100

Pcolor = distance > 0 ? color.green : color.red
// Pcolor = avgval > avgval[1] ? color.green : color.red

plot(distance,title='Color MA', color=Pcolor, linewidth=4)
ronniebrasco33907
underrated
NSahraC
thank you :)
aligafore112
Tankyo
muddy7
thanks, can u add a midline at zero??
更多