RicardoSantos

[RS]Modified McClellan Oscilator V0

Request for jangseohee:
for evaluation...
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study(title="[RS]Modified McClellan Oscilator V0")
//  ||----------------------------------------------------------------------------------------------------------------------------
//  source: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:mcclellan_oscillator
//  Ratio Adjusted Net Advances (RANA): (Advances - Declines)/(Advances + Declines)
//
//    McClellan Oscillator: 19-day EMA of RANA - 39-day EMA of RANA
//
//  19-day EMA* = (Current Day RANA - Prior Day EMA) * .10 + Prior Day EMA)
//  39-day EMA* = (Current Day RANA - Prior Day EMA) * .05 + Prior Day EMA)
//
//  * The first EMA calculation is a simple average. 
//  ||----------------------------------------------------------------------------------------------------------------------------
fast_length = input(title='EMA - Fast Length:', type=integer, defval=19)
slow_length = input(title='EMA - Slow Length:', type=integer, defval=39)
USE_RANA = input(title='Use Ratio Adjustment Net Advancement:', type=bool, defval=true)

advance = cum(close > open ? close - open : 0)
decline = cum(close < open ? open - close : 0)

adv_dec = USE_RANA ? ((advance-decline)/(advance+decline)) : change(close)
ma_fast = ema(adv_dec, fast_length)
ma_slow = ema(adv_dec, slow_length)

mcl_osc = ma_fast-ma_slow
plot(mcl_osc)
hline(0, color=black)