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)