Please find attach below the average distribution indicator of price. It reflects the extreme values of closed price over the last N periods. I add lines treshold that act like frontiers to pretend price are in its extremum values, theses ones are calculated as average of the higher and lower deviation from the N mean.
Because price will always revert to its mean, we can take opposite (contrarian) trades when price crosses upper or lower treshold.
This indicator could even be use for scalping purpose in the same direction of the price when it reach the upper or lower lines.
Feel free to comments and modify this basic vision of mean reversion indicator.
// external parameters :
// MAp = 30
// MaxBars = 500
// divisor = 6
MA = average(Close)[MAp]
if(High>MA) THEN
DevH = (1-(MA/High))*100
ENDIF
if(Low<MA) THEN
DevL = (1-(MA/Low))*100
ENDIF
if(DevH>0) THEN
SignalH=DevH
ELSE
SignalH=0
ENDIF
if(DevL<0) THEN
SignalL=DevL
ELSE
SignalL=0
ENDIF
LastH = 0
LastL = 0
FOR i = 0 TO MaxBars DO
if(DevH[i]>LastH AND DevH[i]<100) THEN
LastH=DevH[i]
ENDIF
if(DevL[i]<LastL AND DevL[i]<100) THEN
LastL=DevL[i]
ENDIF
NEXT
deviation = (LastH+ABS(LastL))/divisor
RETURN deviation COLOURED(255, 255, 0) As "Deviation H" , -deviation As "Deviation L", SignalH As "Signal H", SignalL As "Signal L"