Average distribution of price

Category: Indicators By: Nicolas Created: October 11, 2015, 12:56 PM
October 11, 2015, 12:56 PM
Indicators
1 Comment

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"

 

Download
Filename: average-distribution.itf
Downloads: 232
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...