Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("Waves Decomposition", overlay=false)
- wave_height = input(100)
- wave_duration = input(162)
- wave_duration_bigwave = input(216)
- n = bar_index
- f_cosine_wave(_wave_height, _wave_duration, _n) =>
- _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, _n) =>
- _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, n)
- big_wave = f_cosine_wave2(wave_height, wave_duration_bigwave, n)
- wave_smoothed = ta.sma(wave, 20) // Apply moving average
- big_wave_smoothed = ta.sma(big_wave, 50) // Apply moving average
- plot(series=wave_smoothed, title='Normal Cycle', color=color.new(#FFFFFF, 0))
- plot(series=big_wave_smoothed, title='Big Wave Cycle', color=color.new(#FFFFFF, 0))
- // 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])
- if _total > 0
- _container = _total
- _total := _total / _absolute
- _total
- else
- _container = _total
- _total := 0 - math.abs(_container) / _absolute
- _total
- cr = f_compound_risk(wave_smoothed, 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
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © bit_ai_zine
- //@version=5
- //indicator(title="[Bit_Ai_zone]RSI columns", shorttitle="[Bit_Ai_zone]RSI columns", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
- ma(source, length, type) =>
- switch type
- "SMA" => ta.sma(source, length)
- "Bollinger Bands" => ta.sma(source, length)
- "EMA" => ta.ema(source, length)
- "SMMA (RMA)" => ta.rma(source, length)
- "WMA" => ta.wma(source, length)
- "VWMA" => ta.vwma(source, length)
- rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings") //
- rsiSourceInput = input.source(close, "Source", group="RSI Settings")
- maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
- maLengthInput = input.int(5, title="MA Length", group="MA Settings")
- up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
- down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
- rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
- rsiMA = ma(rsi, maLengthInput, maTypeInput)
- rsicolor = color.rgb(214, 212, 212)
- if rsi < 30
- rsicolor := color.red
- if rsi > 70
- rsicolor := color.green
- if rsi < 20
- rsicolor := color.black
- plot(rsi, "RSI", color=rsicolor , style = plot.style_columns)
- plot(rsiMA, "RSI-based MA", color=color.black)
Advertisement
Add Comment
Please, Sign In to add comment