OPEN-SOURCE SCRIPT

Дивергенции RSI

//version=6
indicator("Дивергенции RSI", shorttitle="RSI Divergence", overlay=true)

// Параметры
rsiLength = input(14, title="Длина RSI")
rsiSource = close

// Расчет RSI
rsi = ta.rsi(rsiSource, rsiLength)

// Определение пиков и впадин
peakPrice = ta.highest(close, 5)
troughPrice = ta.lowest(close, 5)
peakRsi = ta.highest(rsi, 5)
troughRsi = ta.lowest(rsi, 5)

// Логика для определения дивергенций
bullishDiv = (troughPrice[1] < troughPrice) and (troughRsi[1] > troughRsi)
bearishDiv = (peakPrice[1] > peakPrice) and (peakRsi[1] < peakRsi)

// Отображение сигналов на графике
if bullishDiv
label.new(bar_index, low, "Бычья дивергенция", color=color.green, style=label.style_label_up, textcolor=color.white)

if bearishDiv
label.new(bar_index, high, "Медвежья дивергенция", color=color.red, style=label.style_label_down, textcolor=color.white)

// График RSI
hline(70, "Перепроданность", color=color.red)
hline(30, "Перепроданность", color=color.green)
plot(rsi, color=color.blue, title="RSI")
Candlestick analysisforecastingFundamental Analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer