Bogdan Ciocoiu - Litigator
// 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 - Litigator", shorttitle="BC - Litigator", format=format.price, precision=2, timeframe="", timeframe_gaps=true)

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Overall
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_All_line_0 = input(80, "Separator 1", inline="Overall", group="Overall")
_All_line_1 = input(50, "2", inline="Overall", group="Overall")
_All_line_2 = input(20, "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_0>0) ? _All_line_color : na, linestyle=hline.style_dashed)
_All_layer_1 = hline(_All_line_1, "", color=(_All_line_1>0) ? _All_line_color : na, linestyle=hline.style_dashed)
_All_layer_2 = hline(_All_line_2, "", color=(_All_line_2>0) ? _All_line_color : na, linestyle=hline.style_dashed)

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// RSI
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_RSI_mode=input(close, "", inline="RSI", group="RSI")
_RSI_width=input(2, "Wid", inline="RSI", group="RSI")
_RSI_factor=input(1.1, "Fact", inline="RSI", group="RSI")

_RSI_on_1=input(false, "", inline="RSI 1", group="RSI")
_RSI_no_1=input(7, "", inline="RSI 1", group="RSI")
_RSI_col_1=input(color.fuchsia, "", inline="RSI 1", group="RSI")

_RSI_on_2=input(true, "", inline="RSI 2", group="RSI")
_RSI_no_2=input(14, "", inline="RSI 2", group="RSI")
_RSI_col_2=input(color.fuchsia, "", inline="RSI 2", group="RSI")

_RSI_on_3=input(false, "", inline="RSI 3", group="RSI")
_RSI_no_3=input(50, "", inline="RSI 3", group="RSI")
_RSI_col_3=input(color.fuchsia, "", inline="RSI 3", group="RSI")

_RSI_1=ta.rsi(_RSI_mode, _RSI_no_1)*_RSI_factor
_RSI_2=ta.rsi(_RSI_mode, _RSI_no_2)*_RSI_factor
_RSI_3=ta.rsi(_RSI_mode, _RSI_no_3)*_RSI_factor

plot(_RSI_1, color=(_RSI_on_1 and _RSI_width>0) ? _RSI_col_1 : na, linewidth=_RSI_width)
plot(_RSI_2, color=(_RSI_on_2 and _RSI_width>0) ? _RSI_col_2 : na, linewidth=_RSI_width)
plot(_RSI_3, color=(_RSI_on_3 and _RSI_width>0) ? _RSI_col_3 : na, linewidth=_RSI_width)

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// UO
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_UO_on = input(true, "", inline="UO", group="UO")
_UO_color = input(color.aqua, "", inline="UO", group="UO")
_UO_width = input(2, "Wid", inline="UO", group="UO")
_UO_factor = input(1.2, "Fact", inline="UO", group="UO")

_UO_length_1 = input.int(7, "Len 1", inline="UO", group="UO")
_UO_length_2 = input.int(14, "2", inline="UO", group="UO")
_UO_length_3 = input.int(28, "3", inline="UO", group="UO")

_UO_average(_UO_bp, _UO_tr, _UO_length) => math.sum(_UO_bp, _UO_length) / math.sum(_UO_tr, _UO_length)
_UO_high = math.max(high, close[1])
_UO_low = math.min(low, close[1])
_UO_bp = close - _UO_low
_UO_tr = _UO_high - _UO_low
_UO_avg7 = _UO_average(_UO_bp, _UO_tr, _UO_length_1)
_UO_avg14 = _UO_average(_UO_bp, _UO_tr, _UO_length_2)
_UO_avg28 = _UO_average(_UO_bp, _UO_tr, _UO_length_3)
_UO_out = (100 * (4*_UO_avg7 + 2*_UO_avg14 + _UO_avg28)/7)*_UO_factor

plot(_UO_out, title="UO", color=(_UO_on and _UO_width>0) ? _UO_color : na, linewidth=_UO_width)

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Stochastic
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_Stoch_on = input(true, "", inline="Stoch", group="Stoch")
_Stoch_col_up = input(color.new(color.green, 50), "", inline="Stoch", group="Stoch")
_Stoch_col_down = input(color.new(color.red, 50), "", inline="Stoch", group="Stoch")
_Stoch_col_up_2 = input(color.new(color.green, 20), "", inline="Stoch", group="Stoch")
_Stoch_col_down_2 = input(color.new(color.red, 20), "", inline="Stoch", group="Stoch")
_Stoch_wid = input(0, "Wid", inline="Stoch", group="Stoch")

_Stoch_period_K = input(8, "K per", inline="Stoch", group="Stoch")
_Stoch_smooth_K = input(3, "K smo", inline="Stoch", group="Stoch")
_Stoch_period_D = input(5, "D per", inline="Stoch", group="Stoch")

_Stoch_K = ta.sma(ta.stoch(close, high, low, _Stoch_period_K), _Stoch_smooth_K)
_Stoch_D = ta.sma(_Stoch_K, _Stoch_period_D)

_Stoch_K_plot = plot(_Stoch_K, title="Stoch K", color=(_Stoch_on and _Stoch_wid > 0) ? (_Stoch_K > _Stoch_D ? _Stoch_col_up : _Stoch_col_down ) : na, linewidth=_Stoch_wid)
_Stoch_D_plot = plot(_Stoch_D, title="Stoch D", color=(_Stoch_on and _Stoch_wid > 0) ? (_Stoch_K > _Stoch_D ? _Stoch_col_up : _Stoch_col_down ) : na, linewidth=_Stoch_wid)

fill(_Stoch_K_plot, _Stoch_D_plot, color=(_Stoch_on) ? (_Stoch_K > _Stoch_D ? _Stoch_col_up : _Stoch_col_down ) : na)

plotshape(ta.crossover(_Stoch_K, _Stoch_D) ? _Stoch_K : na, location=location.absolute, style=shape.circle, size=size.tiny, color=(_Stoch_on) ? _Stoch_col_up_2 : na)
plotshape(ta.crossunder(_Stoch_K, _Stoch_D) ? _Stoch_K : na, location=location.absolute, style=shape.circle, size=size.tiny, color=(_Stoch_on) ? _Stoch_col_down_2 : na)

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// MFI
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_MFI_on = input(false, title="", group="MFI", inline="MFI")
_MFI_color = input(color.orange, title="", group="MFI", inline="MFI")
_MFI_width = input(2, title="Wid", group="MFI", inline="MFI")
_MFI_length = input(14, title="Len", group="MFI", inline="MFI")
_MFI_src = input(hlc3, title="", group="MFI", inline="MFI")
_MFI_factor = input(1.1, title="Fact", group="MFI", inline="MFI")

_MFI_mf = ta.mfi(_MFI_src, _MFI_length)*_MFI_factor

plot(_MFI_mf, color=(_MFI_on and _MFI_width>0) ? _MFI_color : na, linewidth=_MFI_width)
