RicardoSantos

[RS]Timed Percentual Change V0

EXPERIMENTAL: time based percentual change.

note: each series uses it self as base reference so there's a bit a divergence.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
study(title='[RS]Timed Percentual Change V0', overlay=false)
yyyy = input(2015)
mm = input(08)
dd = input(01)
SHOW_EXTREME = input(title='Show Extreme Range:', type=bool, defval=true)
f_get_percentual_src(_yyyy, _mm, _dd, _srctype)=>
    //--> remove data prior to date.
    _src = year < _yyyy or (year <= _yyyy and month < _mm) or (year <= _yyyy and month <= _mm and dayofmonth < _dd)  ? na : _srctype
    _basis_ad = valuewhen( na(_src[1]), _src, 0)
    _return = (_src/_basis_ad)*100

_open = f_get_percentual_src(yyyy, mm, dd, open)
_high = f_get_percentual_src(yyyy, mm, dd, high)
_low = f_get_percentual_src(yyyy, mm, dd, low)
_close = f_get_percentual_src(yyyy, mm, dd, close)
fc = close>open?lime:close<open?red:gray
plotcandle(_open, _high, _low, _close, color=fc, wickcolor=black)
hline(100, color=black)

top_extreme = na(top_extreme[1]) ? _high : max(max(_high, max(_open, _close)), top_extreme[1])
bot_extreme = na(bot_extreme[1]) ? _low : min(min(_low, min(_open, _close)), bot_extreme[1])

plot(not SHOW_EXTREME ? na : top_extreme, color=change(top_extreme)!=0?na:black)
plot(not SHOW_EXTREME ? na : bot_extreme, color=change(bot_extreme)!=0?na:black)
plot(not SHOW_EXTREME ? na : avg(top_extreme, bot_extreme), color=change(avg(bot_extreme, top_extreme))!=0?silver:black)