//---------------------------------------//
//---------------------------------------//
// Inputs
//---------------------------------------//
len=10
th=20
//---------------------------------------//
// ADX and Directionals
//---------------------------------------//
If barindex>1 then
trueRange=max(max(high-low,abs(high-close[1])),abs(low-close[1]))
if (high-high[1]) > (low[1]-low) then
DMplus=max(high-high[1],0)
else
DMplus=0
endif
if (low[1]-low) > (high-high[1]) then
DMMinus=max(low[1]-low,0)
else
DMMinus=0
endif
SmoothedTrueRange=SmoothedtrueRange[1]-SmoothedtrueRange[1]/len+TrueRange
SmoothedDMplus=SmoothedDMplus[1]-SmoothedDMplus[1]/len+DMplus
SmoothedDMMinus=SmoothedDMMinus[1]-SmoothedDMMinus[1]/len+DMMinus
DIP=SmoothedDMplus/SmoothedTrueRange*100
DIM=SmoothedDMMinus/SmoothedTrueRange*100
DX=ABS(DIP-DIM)/(DIP+DIM)*100
ADX1=AVERAGE[LEN](DX)
smoothDi=(average[5](DIP-DIM)+(DIP-DIM))/2
adxin=(adx1+adx1[14])/2
if adx1 crosses over adxin or adx1 crosses under adx1 then
r=0
g=0
b=0
elsif smoothDi >=0 and adx1>th then
r=0
g=255
b=0
elsif smoothDi<0 and adx1>th then
r=255
g=0
b=0
elsif adx1<th then
r=124
g=124
b=124
else
r=255
g=255
b=255
endif
drawcandle(open,high,low,close)coloured(r,g,b)
endif
//---------------------------------------//
return