//@version=5
indicator(title='<MARSI_RCOT>', shorttitle='<MARSI_RCOT>', overlay=false)
// ����������� ��������� ���������� ����� ���������������� ���������
length1 = [Link](2, title="RSI Length", minval=1)
length2 = [Link](5, title="MA5 Length", minval=1)
length3 = [Link](20, title="MA200 Length", minval=1)
rsiThresholdHigh = [Link](60, title="RSI High Threshold")
rsiThresholdLow = [Link](-60, title="RSI Low Threshold")
// ��������� ����� �� ����������� ���������� �����
centerLineColor = [Link]( [Link](69, 70, 71), title="Center Line Color")
src = close
// RSI Calculation
up = [Link]([Link]([Link](src), 0), length1)
down = [Link](-[Link]([Link](src), 0), length1)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
// MA Calculation
ma5 = [Link](close, length2)
ma200 = [Link](close, length3)
// Color Code
col = close > ma200 and close < ma5 and rsi < rsiThresholdLow ? #fa0000 : close <
ma200 and close > ma5 and rsi > rsiThresholdHigh ? #05ff12 : [Link]
// Graphics Code
lineThresholdHigh = plot(rsiThresholdHigh, title='Lower Line High',
style=plot.style_line, linewidth=1, color=#fc0404)
lineThresholdLow = plot(rsiThresholdLow, title='Upper Line Low',
style=plot.style_line, linewidth=1, color=#02fc0a)
line100 = plot(100, title='Upper Line 100', style=plot.style_line, linewidth=3,
color=#fa010d)
line90 = plot(80, title='Lower Line 80', style=plot.style_line, linewidth=1,
color=#f50404)
line10 = plot(-80, title='Lower Line 20', style=plot.style_line, linewidth=1,
color=#3df704)
line0 = plot(-100, title='Lower Line 0', style=plot.style_line, linewidth=3,
color=#2ef727)
// �������� ���������� �� ������ ���������� �����
centerLine = [Link](x1=bar_index[1], y1=0, x2=bar_index, y2=0,
color=centerLineColor, width=1, style=line.style_dashed)
fill(lineThresholdLow, lineThresholdHigh, color=[Link]([Link], 95))
plot(rsi, title='RSI Line', style=plot.style_line, linewidth=1, color=col)
plot(rsi, title='RSI Dots', style=plot.style_circles, linewidth=2,
color=[Link])
// Define colors
var color gray = #808080
var color green = #00FF00
var color red = #FF0000
sma2 = [Link](close, 2)
dsma2 = [Link](sma2, 2)
tsma2 = [Link](dsma2, 2)
qsma2 = [Link](tsma2, 2)
psma2 = [Link](qsma2, 2)
ssma2 = [Link](psma2, 2)
s2sma2 = [Link](ssma2, 2)
osma2 = [Link](s2sma2, 2)
o2sma2 = [Link](osma2, 2)
desma2 = [Link](o2sma2, 2)
rmax = [Link](sma2, [Link](dsma2, [Link](tsma2, [Link](qsma2,
[Link](psma2, [Link](ssma2, [Link](s2sma2, [Link](osma2, [Link](o2sma2,
desma2)))))))))
rmin = [Link](sma2, [Link](dsma2, [Link](tsma2, [Link](qsma2,
[Link](psma2, [Link](ssma2, [Link](s2sma2, [Link](osma2, [Link](o2sma2,
desma2)))))))))
rosc = 100 * (close - (sma2 + dsma2 + tsma2 + qsma2 + psma2 + ssma2 + s2sma2 +
osma2 + o2sma2 + desma2) / 10) / ([Link](close, 10) - [Link](close, 10))
rbl = -100 * (rmax - rmin) / ([Link](close, 10) - [Link](close, 10))
rbu = -rbl
ml = plot(0)
ll = plot(rbl, color=[Link](gray, 0))
ul = plot(rbu, color=[Link](gray, 0))
plot(rosc, color=rosc >= 0 ? green : red, linewidth=3, style=plot.style_histogram)
fill(ll, ml, [Link](red, 90))
fill(ml, ul, [Link](green, 90))
// Insert the new code below this line
lengthVol = [Link](13, title="Moving Average Length", minval=1)
gasPercent = [Link](90, title="Gas Signal %", minval=51, maxval=100)
var float vAvgVol = 0.0
var float BVol = 0.0
var float SVol = 0.0
nzVolume = nz(volume)
vAvgVol := [Link](nzVolume, lengthVol)
BVol := nzVolume * (close - low) / (high - low)
SVol := nzVolume * (high - close) / (high - low)
BVolPercent = BVol / (BVol + SVol) * 100
SVolPercent = SVol / (BVol + SVol) * 100
varip int BVolGas = na
varip int SVolGas = na
if [Link]
BVolGas := 0
SVolGas := 0
else
BVolGas := BVolPercent >= gasPercent ? BVolGas + 1 : BVolGas
SVolGas := SVolPercent >= gasPercent ? SVolGas + 1 : SVolGas
manipDir = (BVolGas - SVolGas)
groupTableSetup = "Table Setup"
textSizeVol = [Link]("Normal", title="Text Size", options=["Normal", "Small",
"Tiny"], group=groupTableSetup)
volBuy = [Link](BVolPercent, "#.##")
volSell = [Link](SVolPercent, "#.##")
volBuyGas = [Link](BVolGas, [Link])
volSellGas = [Link](SVolGas, [Link])
volCurrent = [Link](BVol + SVol, [Link])
volAverage = [Link](vAvgVol, [Link])
if [Link]
textSizeActual = switch
textSizeVol == "Normal" => [Link]
textSizeVol == "Small" => [Link]
textSizeVol == "Tiny" => [Link]
=> [Link]
var table volInfoTbl = [Link](position.middle_right, 3, 3,
bgcolor=[Link](#000000, 100), frame_color=[Link](#000000, 100),
frame_width=0, border_color=[Link](#000000, 100), border_width=0)
[Link](volInfoTbl, 0, 0, "- buy", text_color=#f3f4f8,
text_size=textSizeActual, text_halign=text.align_right,
text_valign=text.align_center)
[Link](volInfoTbl, 1, 0, "%" + volBuy, text_color=BVolPercent > 50 ?
[Link](#00ff00, 0) : [Link]([Link], 0), text_size=textSizeActual,
text_halign=text.align_left, text_valign=text.align_center)
[Link](volInfoTbl, 2, 0, "( " + volBuyGas + " )", text_color=BVolGas >
SVolGas ? [Link](#00f9ea, 0) : [Link]([Link], 0),
text_size=textSizeActual, text_halign=text.align_left,
text_valign=text.align_center)
[Link](volInfoTbl, 0, 1, "- sell", text_color=#eceef1,
text_size=textSizeActual, text_halign=text.align_right,
text_valign=text.align_center)
[Link](volInfoTbl, 1, 1, "%" + volSell, text_color=SVolPercent >= 50 ?
[Link](#00ff00, 0) : [Link]([Link], 0), text_size=textSizeActual,
text_halign=text.align_left, text_valign=text.align_center)
[Link](volInfoTbl, 2, 1, "( " + volSellGas + " )", text_color=SVolGas >=
BVolGas ? [Link](#00f9ea, 0) : [Link]([Link], 0),
text_size=textSizeActual, text_halign=text.align_left,
text_valign=text.align_center)
[Link](volInfoTbl, 0, 2, "- curr/avrg", text_color=#f8f9fd,
text_size=textSizeActual, text_halign=text.align_right,
text_valign=text.align_center)
[Link](volInfoTbl, 1, 2, volCurrent, text_color=BVol + SVol > vAvgVol ?
[Link](#ffff00, 0) : [Link]([Link], 0), text_size=textSizeActual,
text_halign=text.align_left, text_valign=text.align_center)
[Link](volInfoTbl, 2, 2, volAverage, text_color=vAvgVol > vAvgVol[1] ?
[Link](#ffff00, 0) : [Link]([Link], 0), text_size=textSizeActual,
text_halign=text.align_left, text_valign=text.align_center)