Tracha

Time Series Forecast with WMA

354
Time Series Forecast with WMA
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?
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)