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.
Remove from Favorite Scripts Add to Favorite Scripts
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)

Can you make a "price based percentual change" instead, and exclude the time? The time just makes noise. We onlyc are about the price. And make the input so we can choose how many candles we will calcuate the price change for.
Reply
United States
United Kingdom
India
Deutschland
España
France
Việt Nam
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
Malaysia
日本
한국
简体
繁體
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 Support Priority Support Report Issue Ideas Published Followers Following Private Messages Chat Sign Out