RCI3本を使ったインジケーターです。
買われすぎラインを80 売られすぎラインを-80とし、このラインに短期線、中期線、長期戦いずれかが入り込んだ時にサインが出現します。
サインに合わせてアラートを鳴らすこともできます。
RCI80INインジケーター

コチラがインジケーターを表示させたときの画像。
トレーディングビューの下の段にRCIを3本表示します。
短期線:S
中期線:M
長期戦:L
でサインを表示。サインはそれぞれ表示、非表示切り替えられます。

例えばこの画面のように、短期のサインだけ、中期長期だけなど細かく調整できます。

コチラはパラメータ画面。短期中期長期、買われすぎ売られすぎの数値はそれぞれ設定できます。
ただし、買われすぎ売られすぎのラインを変更したとしても、サインやアラートは±80で固定です。

コチラがスタイル画面。短期中期長期線のラインの色や太さはコチラで変更可能です。

コチラがアラート画面。
短期、中期、長期の買いサイン売りサインに合わせて設定できます。
RCI80INインジケーターコード
//@version=5
indicator("RCI 80 in", overlay=false, shorttitle="RCI 80 in", max_labels_count=500)
// Input parameters
itvs = input(9, "Short Term RCI Period")
itvm = input(26, "Mid Term RCI Period")
itvl = input(52, "Long Term RCI Period")
upperband = input(80, "Overbought")
lowerband = input(-80, "Oversold")
showShortSignals = input(true, "Show Short Term Signals")
showMidSignals = input(true, "Show Mid Term Signals")
showLongSignals = input(true, "Show Long Term Signals")
// RCI calculation function
d(itv) =>
sum = 0.0
for i = 0 to itv - 1
o = 1.0
s = 0.0
p = close[i]
for j = 0 to itv - 1
if p < close[j]
o := o + 1
else if p == close[j]
s := s + 1
rank = o + (s - 1) / 2.0
sum := sum + math.pow((i + 1) - rank, 2)
sum
rci(itv) => (1.0 - 6.0 * d(itv) / (itv * (itv * itv - 1.0))) * 100.0
// Calculate RCI values once
rciShort = rci(itvs)
rciMid = rci(itvm)
rciLong = rci(itvl)
// Signal calculations (fixed logic)
sellSignal1 = showShortSignals and ta.crossunder(rciShort, upperband) // RCI crosses under overbought
buySignal1 = showShortSignals and ta.crossover(rciShort, lowerband) // RCI crosses over oversold
sellSignal2 = showMidSignals and ta.crossunder(rciMid, upperband)
buySignal2 = showMidSignals and ta.crossover(rciMid, lowerband)
sellSignal3 = showLongSignals and ta.crossunder(rciLong, upperband)
buySignal3 = showLongSignals and ta.crossover(rciLong, lowerband)
// Plot RCI lines
plot(rciShort, color=color.red, title="Short Term RCI", linewidth=2)
plot(rciMid, color=color.green, title="Mid Term RCI", linewidth=2)
plot(rciLong, color=color.blue, title="Long Term RCI", linewidth=2)
// Plot reference lines
hline(upperband, "Overbought", color=color.gray, linestyle=hline.style_dashed)
hline(lowerband, "Oversold", color=color.gray, linestyle=hline.style_dashed)
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted)
// Signal labels with offset to avoid overlap
var int labelOffset = 0
if sellSignal1 or sellSignal2 or sellSignal3
labelY = upperband + 5
labelText = ""
labelColor = color.red
if sellSignal1
labelText := labelText + "S"
labelColor := color.red
if sellSignal2
labelText := labelText + "M"
labelColor := sellSignal1 ? color.orange : color.green
if sellSignal3
labelText := labelText + "L"
labelColor := (sellSignal1 or sellSignal2) ? color.purple : color.blue
label.new(x=bar_index, y=labelY, style=label.style_label_down,
color=labelColor, text="▼" + labelText, size=size.small,
textcolor=color.white)
if buySignal1 or buySignal2 or buySignal3
labelY = lowerband - 5
labelText = ""
labelColor = color.green
if buySignal1
labelText := labelText + "S"
labelColor := color.red
if buySignal2
labelText := labelText + "M"
labelColor := buySignal1 ? color.orange : color.green
if buySignal3
labelText := labelText + "L"
labelColor := (buySignal1 or buySignal2) ? color.purple : color.blue
label.new(x=bar_index, y=labelY, style=label.style_label_up,
color=labelColor, text="▲" + labelText, size=size.small,
textcolor=color.white)
// Alerts with corrected descriptions
alertcondition(sellSignal1, title="Short Term Sell Signal Alert",
message="Short Term RCI has crossed under overbought level!")
alertcondition(buySignal1, title="Short Term Buy Signal Alert",
message="Short Term RCI has crossed over oversold level!")
alertcondition(sellSignal2, title="Mid Term Sell Signal Alert",
message="Mid Term RCI has crossed under overbought level!")
alertcondition(buySignal2, title="Mid Term Buy Signal Alert",
message="Mid Term RCI has crossed over oversold level!")
alertcondition(sellSignal3, title="Long Term Sell Signal Alert",
message="Long Term RCI has crossed under overbought level!")
alertcondition(buySignal3, title="Long Term Buy Signal Alert",
message="Long Term RCI has crossed over oversold level!")
// Combined alerts for multiple timeframes
alertcondition(sellSignal1 or sellSignal2 or sellSignal3, title="Any RCI Sell Signal",
message="RCI Sell Signal detected!")
alertcondition(buySignal1 or buySignal2 or buySignal3, title="Any RCI Buy Signal",
message="RCI Buy Signal detected!")
※2025/9 表示を修正しました。
コピペで使えるハズです。
不具合などあれば直しますのでコメントなどで教えてください。


コメント