Skip to main content
BTC / USDTCRYPTO107,400+2.19%ETH / USDTCRYPTO3,840+2.13%SOL / USDTCRYPTO182.40−1.99%BNB / USDTCRYPTO652.30+0.66%XRP / USDTCRYPTO2.2150+1.61%DOGE / USDTCRYPTO0.3850−1.79%TON / USDTCRYPTO5.240+2.34%AVAX / USDTCRYPTO42.60−2.07%LINK / USDTCRYPTO22.40+2.28%ADA / USDTCRYPTO1.0520−1.68%TRX / USDTCRYPTO0.3300+0.92%DOT / USDTCRYPTO8.420+2.93%BTC / USDTCRYPTO107,400+2.19%ETH / USDTCRYPTO3,840+2.13%SOL / USDTCRYPTO182.40−1.99%BNB / USDTCRYPTO652.30+0.66%XRP / USDTCRYPTO2.2150+1.61%DOGE / USDTCRYPTO0.3850−1.79%TON / USDTCRYPTO5.240+2.34%AVAX / USDTCRYPTO42.60−2.07%LINK / USDTCRYPTO22.40+2.28%ADA / USDTCRYPTO1.0520−1.68%TRX / USDTCRYPTO0.3300+0.92%DOT / USDTCRYPTO8.420+2.93%
Precios

RSI (Relative Strength Index)

The classic 0–100 momentum oscillator — ready-to-paste code for MT4, MT5, TradeStation and TradingView.

RSI measures the speed and magnitude of recent price changes on a 0–100 scale. Readings above 70 signal overbought conditions and below 30 oversold; many traders also use the 50 line as a simple trend bias. Copy the version for your platform below.

MetaTrader 4 (MQL4)

MQL4 · RSI.mq4
#property indicator_separate_window
#property indicator_buffers 1

extern int RSI_Period = 14;
double RsiBuffer[];

int OnInit() {
  SetIndexBuffer(0, RsiBuffer);
  IndicatorShortName("RSI(" + RSI_Period + ")");
  return 0;
}

int OnCalculate(const int rates_total, const int prev_calculated, const double &close[]) {
  for (int i = prev_calculated; i < rates_total; i++)
    RsiBuffer[i] = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, i);
  return rates_total;
}

MetaTrader 5 (MQL5)

MQL5 · RSI.mq5
#property indicator_separate_window
#property indicator_buffers 1

input int RSI_Period = 14;
double RsiBuffer[];

int OnInit() {
  SetIndexBuffer(0, RsiBuffer);
  IndicatorSetString(INDICATOR_SHORTNAME, "RSI(" + IntegerToString(RSI_Period) + ")");
  return INIT_SUCCEEDED;
}

int OnCalculate(const int rates_total, const int prev_calculated,
  const datetime &time[], const double &open[], const double &high[],
  const double &low[], const double &close[], const long &tick_volume[],
  const long &volume[], const int &spread[]) {
  for (int i = prev_calculated; i < rates_total; i++)
    RsiBuffer[i] = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, i);
  return rates_total;
}

TradeStation (EasyLanguage)

EasyLanguage
inputs: Length(14);
variables: MyRSI(0);
MyRSI = RSI(Close, Length);
Plot1(MyRSI, "RSI");

TradingView (Pine Script)

Pine Script
//@version=5
indicator("RSI", overlay=false)
length = input.int(14, "RSI Length")
overbought = input.float(70.0, "Overbought")
oversold = input.float(30.0, "Oversold")
rsiValue = ta.rsi(close, length)
plot(rsiValue, title="RSI", color=color.purple, linewidth=2)
hline(overbought)
hline(oversold)
hline(50)

Want it inside dtcharts? Open the Script Converter, paste any version above, and it converts to a native indicator you can drop on the chart. Every snippet here is tested to convert cleanly.

¿Te ha sido útil?