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%

OBV (On Balance Volume)

Cumulative volume-pressure line — MT4, MT5, TradingView, TradeStation and MetaStock code.

OBV keeps a running total that adds the bar's volume on an up-close and subtracts it on a down-close. Rising OBV confirms the buying pressure behind an uptrend; OBV/price divergence often precedes a reversal. Copy the version for your platform.

Pine Script
//@version=5
indicator("On Balance Volume", overlay=false)
obv = ta.cum(math.sign(ta.change(close)) * volume)
plot(obv, title="OBV", color=color.blue, linewidth=2)
MQL4 · OBV.mq4
#property indicator_separate_window
#property indicator_buffers 1

double ObvBuffer[];

int OnInit() {
  SetIndexBuffer(0, ObvBuffer);
  IndicatorShortName("OBV");
  return 0;
}

int OnCalculate(const int rates_total, const int prev_calculated, const double &close[]) {
  for (int i = prev_calculated; i < rates_total; i++)
    ObvBuffer[i] = iOBV(NULL, 0, PRICE_CLOSE, i);
  return rates_total;
}
MQL5 · OBV.mq5
#property indicator_separate_window
#property indicator_buffers 1

double ObvBuffer[];

int OnInit() {
  SetIndexBuffer(0, ObvBuffer);
  IndicatorSetString(INDICATOR_SHORTNAME, "OBV");
  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++)
    ObvBuffer[i] = iOBV(NULL, 0, PRICE_CLOSE, i);
  return rates_total;
}
EasyLanguage
variables: MyOBV(0);
MyOBV = OBV();
Plot1(MyOBV, "OBV");
MetaStock
{On Balance Volume}
vol := OBV();
vol

To use it inside dtcharts, paste any version into the Script Converter and it becomes a native indicator on your chart.

क्या यह सहायक था?