moslem for BINANCE:SHIBUSDT by moslem8752

study(“Goslin PaintBars + Moving Average”, overlay=true, shorttitle=”GoslinBars+SMA”)

//by @behrouz_m_h

//inputs

fastLength = input(3, minval=1)

slowLength = input(10, minval=2)

MALength = input(16, minval=1)

len = input(49, minval=1, title=”Length”)

sllen = input(21, minval=1, title=”Stop loss period”)

src = input(close, title=”Source”)

shift = input(5, title=”shift”)

ADXlen = input(title=”ADX Length”, type=integer, defval=14)

gpb = input(true, title=”Color Concurrent Bars?”)

mnlb=input(false, title=”Color Crosscurrent Bars?” )

//formulas

fastsma = sma (close, fastLength)

slowsma = sma (close, slowLength)

diff = fastsma-slowsma

dottedline=sma(diff, MALength)

out = sma ( src , len )

uptrend = (change(dottedline) >= 0 and change(out) >= 0)

downtrend = (change(dottedline)

//colored SMA

plot(out, color = change(out)

//trailing stop

TS = sma ( src , sllen)

plot( TS , color=#9d9d9d, title=”TS”, offset=shift)

//goslin paintbars

bc = (gpb ? uptrend ? #27b700 : downtrend ? #ff0000 : mnlb?#858585:na : (not (uptrend or downtrend) and mnlb ? #858585 : na ) )

barcolor( bc )

// ADX background

TrueRange = max(max( high-low , abs(high-nz(close))), abs(low-nz(close)))

DirectionalMovementPlus = high-nz(high) > nz (low)-low ? max(high-nz(high), 0): 0

DirectionalMovementMinus = nz (low)-low > high-nz(high) ? max( nz (low)-low, 0): 0

SmoothedTrueRange = nz (SmoothedTrueRange) – ( nz (SmoothedTrueRange)/ADXlen) + TrueRange

SmoothedDirectionalMovementPlus = nz (SmoothedDirectionalMovementPlus) – ( nz (SmoothedDirectionalMovementPlus)/ADXlen) + DirectionalMovementPlus

SmoothedDirectionalMovementMinus = nz (SmoothedDirectionalMovementMinus) – ( nz (SmoothedDirectionalMovementMinus)/ADXlen) + DirectionalMovementMinus

DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100

DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100

DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100

ADX = sma ( DX , ADXlen)

backgound = ( ADX < 20 ? #fff9c4 : ADX > 20 and ADX < 30 ? #ffee58 :ADX > 30 ? #f57f17 : na)

bgcolor(color=backgound , title = “ADX Approval”, transp=65)

Source link