Bogdan Ciocoiu - Moonshot
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BogdanCiocoiu

//@version=5
indicator("Bogdan Ciocoiu - Moonshot", shorttitle="BC - Moonshot", format=format.price, precision=2, timeframe="", timeframe_gaps=true, explicit_plot_zorder=true)

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Overall
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_All_line_0 = input(40, "Separator 1", inline="Overall", group="Overall")
_All_line_1 = input(0, "2", inline="Overall", group="Overall")
_All_line_2 = input(-40, "3", inline="Overall", group="Overall")

_All_line_color = input(color.new(color.white, 70), "", inline="Overall", group="Overall")

_All_layer_0 = hline(_All_line_0, "", color=_All_line_color, linestyle=hline.style_dashed)
_All_layer_1 = hline(_All_line_1, "", color=_All_line_color, linestyle=hline.style_dashed)
_All_layer_2 = hline(_All_line_2, "", color=_All_line_color, linestyle=hline.style_dashed)

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// TSI
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_TSI_enable = input(true, "", inline="TSI", group="TSI")

_TSI_col_l = input(color.new(color.green, 50), "", inline="TSI", group="TSI")
_TSI_col_s = input(color.new(color.red, 50), "", inline="TSI", group="TSI")
_TSI_col_l_2 = input(color.new(color.green, 20), "", inline="TSI", group="TSI")
_TSI_col_s_2 = input(color.new(color.red, 20), "", inline="TSI", group="TSI")

_TSI_src = input(close, "", inline="TSI", group="TSI")
_TSI_width = input(0, title="Wid", inline="TSI", group="TSI")

_TSI_long_length = input(6, title="Lon", inline="TSI", group="TSI")
_TSI_short_length = input(13, title="Sho", inline="TSI", group="TSI")
_TSI_signal_length = input(4, title="Sig", inline="TSI", group="TSI")

_TSI_mom = ta.change(_TSI_src)
_TSI_numerator = ta.ema(ta.ema(_TSI_mom, _TSI_long_length), _TSI_short_length)
_TSI_denominator = ta.ema(ta.ema(math.abs(_TSI_mom), _TSI_long_length), _TSI_short_length)
_TSI_tsi = 100 * _TSI_numerator / _TSI_denominator
_TSI_signal = ta.ema(_TSI_tsi, _TSI_signal_length)

_TSI_trend_color = (_TSI_tsi > _TSI_signal) ? _TSI_col_l : _TSI_col_s

_TSI_tsi_plot = plot(_TSI_tsi, color=(_TSI_enable and _TSI_width>0) ? _TSI_trend_color : na, linewidth=_TSI_width)
_TSI_signal_plot = plot(_TSI_signal, color=(_TSI_enable and _TSI_width>0) ? _TSI_trend_color : na, linewidth=_TSI_width)

fill(_TSI_tsi_plot, _TSI_signal_plot, color=(_TSI_enable) ? _TSI_trend_color : na)

plotshape(ta.crossover(_TSI_tsi, _TSI_signal) ? _TSI_tsi : na, location=location.absolute, style=shape.circle, size=size.tiny, color=(_TSI_enable) ? _TSI_col_l_2 : na)
plotshape(ta.crossunder(_TSI_tsi, _TSI_signal) ? _TSI_tsi : na, location=location.absolute, style=shape.circle, size=size.tiny, color=(_TSI_enable) ? _TSI_col_s_2 : na)

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// MACD
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_MACD_enable = input(false, "", inline="MACD", group="MACD")
_MACD_col = input(color.aqua, "", inline="MACD", group="MACD")
_MACD_src = input(close, "", inline="MACD", group="MACD")
_MACD_width = input(2, title="Wid", inline="MACD", group="MACD")

_MACD_multi_factor = input(5, "Fact", inline="MACD", group="MACD")

_MACD_fast_len = input(12, "Fast", inline="MACD", group="MACD")
_MACD_slow_len = input(26, "Slow", inline="MACD", group="MACD")
_MACD_sig_len = input(9, "Smo", inline="MACD", group="MACD")
_MACD_sma_src = input.string("EMA", title="Oscillator MA", options=["SMA", "EMA"], inline="MACD", group="MACD")
_MACD_sma_sig = input.string("EMA", title="Signal MA", options=["SMA", "EMA"], inline="MACD", group="MACD")

_MACD_ma_f = _MACD_sma_src == "SMA" ? ta.sma(_MACD_src, _MACD_fast_len) : ta.ema(_MACD_src, _MACD_fast_len)
_MACD_ma_s = _MACD_sma_src == "SMA" ? ta.sma(_MACD_src, _MACD_slow_len) : ta.ema(_MACD_src, _MACD_slow_len)
_MACD_md = _MACD_ma_f - _MACD_ma_s
_MACD_sig = _MACD_sma_sig == "SMA" ? ta.sma(_MACD_md, _MACD_sig_len) : ta.ema(_MACD_md, _MACD_sig_len)
_MACD_his = _MACD_md - _MACD_sig
_MACD_his := _MACD_his * _MACD_multi_factor

plot(_MACD_his, style=plot.style_line, color=(_MACD_enable and _MACD_width>0) ? _MACD_col : na, linewidth=_MACD_width)

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// AO
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_AO_enable = input(true, "", inline="AO", group="AO")
_AO_col = input(color.orange, "", inline="AO", group="AO")
_AO_width = input(2, title="Wid", inline="AO", group="AO")

_AO_multi_factor = input(1, "Fact", inline="AO", group="AO")

_AO_ao = ta.sma(hl2,5) - ta.sma(hl2,34)
_AO_ao := _AO_ao * _AO_multi_factor
_AO_diff = _AO_ao - _AO_ao[1]

plot(_AO_ao, color=(_AO_enable and _AO_width>0) ? _AO_col : na, style=plot.style_line, linewidth=_AO_width)

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// CCI
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_CCI_enable = input(true, "", inline="CCI", group="CCI")
_CCI_col = input(color.fuchsia, "", inline="CCI", group="CCI")
_CCI_width = input(2, "Wid", inline="CCI", group="CCI")

_CCI_multi_factor = input(0.2, "Fac", inline="CCI", group="CCI")

_CCI_src = input(hlc3, "", inline="CCI", group="CCI")
_CCI_length = input(20, "Len", inline="CCI", group="CCI")

_CCI_ma = ta.sma(_CCI_src, _CCI_length)
_CCI_cci = (_CCI_src - _CCI_ma) / (0.015 * ta.dev(_CCI_src, _CCI_length))
_CCI_cci := _CCI_cci * _CCI_multi_factor

plot(_CCI_cci, "CCI", color=(_CCI_enable and _CCI_width>0) ? _CCI_col : na, linewidth=_CCI_width)
