Tracha

Time Series Forecast with WMA

354
Time Series Forecast with WMA
Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?
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)