RicardoSantos

[RS]Linear Decay Oscilator V0

EXPERIMENTAL: binary oscillator based on linear regression .
the master line has 1/4 of the decay.
Remove from Favorite Scripts Add to Favorite Scripts
study(title="[RS]Linear Decay Oscilator V0")
src = input(title='Source:', type=source, defval=hl2)
smoothing = input(title='Source Smoothing:', type=integer, defval=4)
decay = input(title='Decay:', type=float, defval=0.001)

smooth_src = sma(src, smoothing)

previous_lr = nz(lr[1], smooth_src)
lr = smooth_src > previous_lr ? previous_lr+decay : smooth_src < previous_lr ? previous_lr-decay : previous_lr

previous_master_lr = nz(master_lr[1], smooth_src)
master_lr = smooth_src > previous_master_lr ? previous_master_lr+decay/4 : smooth_src < previous_master_lr ? previous_master_lr-decay/4 : previous_master_lr

macd = sma(smooth_src-lr, smoothing)
signal = macd > 0 ? 1 : macd < 0 ? -1 : 0

master_macd = sma(smooth_src-master_lr, smoothing)
master_signal = master_macd > 0 ? 1 : master_macd < 0 ? -1 : 0

plot(title='Follower', series=signal, style=columns, color=signal > 0 and master_signal > 0 ? green : signal < 0 and master_signal < 0 ? maroon : gray, transp=75)
plot(title='Master', series=master_signal, color=master_signal > 0 ? green : master_signal < 0 ? maroon : gray, linewidth=4)
hline(title='0', price=0, color=black)
Very nice my friend. Too bad pine cannot support a linear regression channel that moves with price.
Reply
United States
United Kingdom
India
Deutschland
France
España
Italia
Polska
Türkiye
Россия
Brasil
Indonesia
Malaysia
Việt Nam
日本
한국
简体
繁體
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 Priority Support Contact Support Ideas Published Followers Following Private Messages Chat Sign Out