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)
Futuraman PRO
2 years ago
Very nice my friend. Too bad pine cannot support a linear regression channel that moves with price.
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
France
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Forex Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out