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)