RicardoSantos

[RS]Simple ZigZag V2

EXPERIMENTAL: Method to improve the zigzag , best method so far...
Remove from Favorite Scripts Add to Favorite Scripts
study("[RS]Simple ZigZag V2", overlay=true)
TF = input('240')

f_zigzag(_TF)=>
    _hh = security(tickerid, _TF, high)
    _ll = security(tickerid, _TF, low)
    _output = high >= _hh ? high : low <= _ll ? low : na
f_tops(_TF)=>
    _hh = security(tickerid, _TF, high)
    _ll = security(tickerid, _TF, low)
    _output = high >= _hh ? high : na
f_bots(_TF)=>
    _hh = security(tickerid, _TF, high)
    _ll = security(tickerid, _TF, low)
    _output = low <= _ll ? low : na

tops = f_tops(TF)
bots = f_bots(TF)
zigzag = f_zigzag(TF)

plot(tops, color=gray, linewidth=2)
plot(bots, color=gray, linewidth=2)
plot(zigzag, color=black, linewidth=3)

f_fix_zigzag(_zigzag)=>
    _hh = _zigzag ? close : high >= nz(_hh[1]) ? highest(2) : nz(_hh[1])
    _ll = _zigzag ? close : low <= nz(_ll[1]) ? lowest(2) : nz(_ll[1])
    _isBhigh = valuewhen(_zigzag, _zigzag >= high, 1)
    _isChigh = valuewhen(_zigzag, _zigzag >= high, 0)
    _isBlow = valuewhen(_zigzag, _zigzag <= low, 1)
    _isClow = valuewhen(_zigzag, _zigzag <= low, 0)
    _output = _zigzag and _isBhigh and _isChigh ? _ll[1] :_zigzag[1] and _isBhigh[1] and _isChigh[1] ? _hh :
        _zigzag and _isBlow and _isClow ? _hh[1] : _zigzag[1] and _isBlow[1] and _isClow[1] ? _ll : _zigzag

fix_zz = f_fix_zigzag(zigzag)
plot(fix_zz, color=aqua, linewidth=2)

last_zz_a = valuewhen(zigzag, zigzag, 2)
last_zz_b = valuewhen(zigzag, zigzag, 1)
last_zz_c = valuewhen(zigzag, zigzag, 0)

ab_dif = abs(last_zz_a-last_zz_b)
bc_dif = abs(last_zz_b-last_zz_c)

fib1 = last_zz_c >= high ? last_zz_c - ab_dif : last_zz_c <= low ? last_zz_c + ab_dif : nz(fib1[1])
fib2 = last_zz_c >= high ? last_zz_c - bc_dif : last_zz_c <= low ? last_zz_c + bc_dif : nz(fib2[1])
plot(fib1, color=gray, style=cross, linewidth=1)
plot(fib2, color=silver, style=cross, linewidth=1)
hi RicardoSantos , I'm really impressed your zigzag project. thank you a lot for sharing. It will be really helpful
:O
Reply
RicardoSantos MIchaelTran
np, thx :)
Reply
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out