Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study(title="[RS]Compounded Risk Score", shorttitle="CRS")
- // if you took a trade for every bars close for the duration of the length
- // how would those trades fair atm?
- // values closer to (100 | -100) are better for its (bull | bear), closer to 0 will be closer to break eaven.
- // this indicator is optimal for trending markets.
- length = input(100)
- avg_length = input(25)
- f_compound_risk(_source, _length) =>
- _total = 0.0
- _absolute = 0.0
- for _i = 1 to _length by 1
- _container0 = _total
- _container1 = _absolute
- _total := _container0 + _source[0] - _source[_i]
- _absolute := _container1 + abs(_source[0] - _source[_i])
- _absolute
- if _total > 0
- _container = _total
- _total := _total / _absolute
- _total
- else
- _container = _total
- _total := 0 - abs(_container) / _absolute
- _total
- _total * 100
- cr = f_compound_risk(close, length)
- ma = ema(cr, avg_length)
- plot(series=cr, color=color.black, transp=0)
- plot(series=ma, color=color.navy, transp=0)
- hline(100)
- hline(50)
- hline(0)
- hline(-50)
- hline(-100)
- //end of this part
- //@version=4
- //study(title="CMO(HMA)", overlay=false)
- nHMA = input(title="HMA period", type=input.integer, defval=7)
- HMA = wma(2 * wma(close, round(nHMA / 2)) - wma(close, nHMA), round(sqrt(nHMA)))
- // Use algorithm from the following website
- // http://www.technicalindicators.net/indicators-technical-analysis/144-cmo-chande-momentum-oscillator
- CMO1 = iff(HMA[0] > HMA[1], HMA[0] - HMA[1], 0.0)
- CMO2 = iff(HMA[0] < HMA[1], HMA[1] - HMA[0], 0.0)
- CMO = iff(CMO1 == 0.0 and CMO2 == 0.0, 0.0 * (CMO1 - CMO2), 100 * ((CMO1 - CMO2) / (CMO1 + CMO2)))
- plot(CMO, "CMO(HMA)", linewidth=3, color=color.teal)
Advertisement
Add Comment
Please, Sign In to add comment