Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © DarkPoolTrading
- // Based on the Function Sine Wave Indicator by RicardoSantos
- //@version=5
- indicator(title='Function Cosine Wave', precision=12)
- wave_height = input(100)
- wave_duration = input(161)
- wave_duration_bigwave = input(217)
- n = bar_index
- f_cosine_wave(_wave_height, _wave_duration) =>
- _pi = 3.14159265359
- _w = 2 * _pi / _wave_duration
- _cosine_wave = _wave_height * math.sin(_w * n + _pi / 2)
- _cosine_wave
- f_cosine_wave2(_wave_height, _wave_duration_bigwave) =>
- _pi = 3.14159265359
- _w2 = 2 * _pi / _wave_duration_bigwave
- _cosine_wave2 = _wave_height * math.sin(_w2 * n + _pi / 2)
- _cosine_wave2
- wave = f_cosine_wave(wave_height, wave_duration)
- //wave2 = f_cosine_wave(wave_height, close)
- big_wave = f_cosine_wave2(wave_height, wave_duration_bigwave)
- plot(series=wave, title='Normal', color=color.new(#FFFFFF, 0))
- plot(series=big_wave, title='Normal', color=color.new(#FFFFFF, 0))
- //plot(series=wave2, title='Price as cycle duration', color=#C9A0DC)
- //end of this part
- //end of this part
- //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 + math.abs(_source[0] - _source[_i])
- _absolute
- if _total > 0
- _container = _total
- _total := _total / _absolute
- _total
- else
- _container = _total
- _total := 0 - math.abs(_container) / _absolute
- _total
- _total * 100
- //inp = input(close)
- cr = f_compound_risk(wave, length)
- ma = ta.ema(cr, avg_length)
- plot(series=cr, color=color.new(color.black, 0))
- plot(series=ma, color=color.new(color.navy, 0))
- hline(100)
- hline(50)
- hline(0)
- hline(-50)
- hline(-100)
- //end of this part
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement