Buongiorno,
richiedo cortese traduzione del seguente codice mi sembra piuttosto interessante mi piacerebbe testarlo; grazie come sempre per l’aiuto prezioso.
https://www.tradingview.com/script/ZTxqGBuF/
//@version=2
study(“ADX Candle”,overlay=true)
len = input(title=”Length”, type=integer, defval=10)
th = input(title=”threshold”, type=integer, defval=20)
TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0
SmoothedTrueRange = nz(SmoothedTrueRange[1]) – (nz(SmoothedTrueRange[1])/len) + TrueRange
SmoothedDirectionalMovementPlus = nz(SmoothedDirectionalMovementPlus[1]) – (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = nz(SmoothedDirectionalMovementMinus[1]) – (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus
DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
ADX = sma(DX, len)
//smooth DI
di=(sma((DIPlus-DIMinus),5)+(DIPlus-DIMinus))/2
adxin=(ADX+ADX[14])/2
cy=cross(ADX,adxin)?black:di>=0 and ADX>th?lime:di<0 and ADX>th?red:ADX<th?silver:na
barcolor(color=cy)
Ecco qui
//---------------------------------------//
//---------------------------------------//
// 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