Tracha

Time Series Forecast with WMA

354
Time Series Forecast with WMA
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study("The system no.1", shorttitle="System no.1", overlay=true)

_length = input(title="Length", type=integer, defval=21)
_offset = input(title="Offset", type=integer, defval=0)

_smooth = input(title="WMA Length", type=integer, defval=8, minval=1)


_source = close

_lsma = linreg(_source, _length, _offset)
_lsmaS = wma(_lsma, _smooth)
_lsmaC = cross(_lsma, _lsmaS) ? (_lsma + _lsmaS) * 0.5 : na
//iscross() => _lsmaC
plot(_lsma, color=white, linewidth=2)
plot(_lsmaS, color=#2299CC, linewidth=2)
plotshape(_lsmaC, color=green, style=shape.xcross)

//barcolor(iscross() ? yellow : na)

//coppock

wmaLength = input(title="WMA Length", type=integer, defval=10)
longRoCLength = input(title="Long RoC Length", type=integer, defval=14)
shortRoCLength = input(title="Short RoC Length", type=integer, defval=11)

_crossoverMA = input(title="Crossover WMA Lenth", defval=5, minval=1)
_histogramMultiplier = input(title="Histogram Multiplier", defval=2, type=float)

_sourcec = close

_curve = wma(roc(_sourcec, longRoCLength) + roc(_sourcec, shortRoCLength), wmaLength)
_curveWMA = wma(_curve, _crossoverMA)

_h = (_curve - _curveWMA) * _histogramMultiplier

_curveWMAx = cross(_curve, _curveWMA) ? (_curve + _curveWMA) * 0.5 : na

//final decision
check(x,y) => cross(_curve[x], _curveWMA[x]) and cross(_lsma[y], _lsmaS[y])
check00 = check(0,0)
check01 = check(0,1)
check02 = check(0,2)
check10 = check(1,0)
//check11 = check(1,1)
//check12 = check(1,2)
check20 = check(2,0)
//check21 = check(2,1)
check03 = check(0,3)
//check13 = check(1,3)
//check23 = check(2,3)
check30 = check(3,0)
//check22 = check(2,2)
checkcross = (check00 ? true : check01 ? true : check02 ? true : check10 ? true : check30 ? true :
        check20 ? true : check03 ? true : na)



//checking value
mathcall = (abs(lowest(_curve,50)) + abs(highest(_curve,50))) * 0.3
highalert = highest(_curve,50) - mathcall
lowalert = lowest(_curve,50) + mathcall 

// sell position
sellcheck =  _curveWMA > _curve ? true : false
sellcheck1 =  _lsma < _lsmaS ? true : false
sellcheck2 = _curve>highalert

SELLSIGNAL = checkcross and sellcheck and sellcheck1 and sellcheck2
barcolor(SELLSIGNAL ? yellow : na)

// buy position
buycheck =  _curveWMA < _curve ? true : false
buycheck1 =  _lsma > _lsmaS ? true : false
buycheck2 = _curve<lowalert

BUYSIGNAL = checkcross and buycheck and buycheck1 and buycheck2
barcolor(BUYSIGNAL ? blue : na)