The Universal indicator by John Ehlers plotted directly on the chart, for an immediate understanding of its state. It has been implemented with the moving average of the oscillator, the overbought and oversold areas, and the colors indicating the direction of the trend. Suitable for any chart and time frame.
Indicator interface
How it can be used:
//www.automatictrading.it
///////////////////////INDICATOR_UNIVERSAL
maPrice = customclose
bandedge= UniversalPeriod
whitenoise= (maPrice - maPrice[min(UniversalPeriod,UniversalFilter)])/2
if barindex>bandedge then
a1= Exp(-1.414 * 3.14159 / bandedge)
b1= 2*a1 * Cos(1.414*180 /bandedge)
c2= b1
c3= -a1 * a1
c1= 1 - c2 - c3
filt= c1 * (whitenoise + whitenoise[1])/2 + c2*filt[1] + c3*filt[1]
filt1 = filt
if ABS(filt1)>pk[1] then
pk = ABS(filt1)
else
pk = 0.991 * pk[1]
endif
if pk=0 then
denom = -1
else
denom = pk
endif
if denom = -1 then
result = result[1]
else
result = filt1/pk
endif
endif
///////////////////////////////////////////////////
dTR = 0
for i = 0to ATRperiod-1
dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
next
dtr=dtr/MAX(1,TightenChannel)
avgRange = dTR
maValue = average[max(1,AveragePeriod),AverageMethod](maPrice)
ResultValue = RESULT
Buffer1=maValue
Buffer2=maValue+(avgRange*((overBought)))
Buffer3=maValue-(avgRange*( (overSold)))
Buffer4=maValue+(ResultValue)/1*avgRange
Buffer5=maValue+(avgRange*((10/10)))
Buffer6=maValue+(avgRange*((-10/10)))
if UniAvg then
UniAvgline=Average[UniAvgPeriod](buffer4)
ELSE
UniAvgline=UNDEFINED
endif
MyUNI = result
R = 50+(200-MyUNI*400)
G =50+(200+MyUNI*500)
DRAWCANDLE(Buffer2, Buffer3, Buffer2, Buffer3)coloured(R,G,0,40)
return Buffer1 coloured(0,0,0) style(dottedline,1) as "0 level", Buffer2 coloured(0,0,0) style(dottedline,1) as "overbought level", Buffer3 coloured(0,0,0) style(dottedline,1) as "oversold level", Buffer4 coloured(0,130,250) style(LINE,2) as "UNIVERSAL VALUE",Buffer5 AS"1 level",Buffer6 AS"-1 level",UniAvgline coloured(250,150,0) style(dottedline,1) AS" UniversalAverage"