Skip to main content
BTC / USDT———ETH / USDT———SOL / USDT———BNB / USDT———XRP / USDT———DOGE / USDT———TON / USDT———AVAX / USDT———LINK / USDT———ADA / USDT———TRX / USDT———DOT / USDT———BTC / USDT———ETH / USDT———SOL / USDT———BNB / USDT———XRP / USDT———DOGE / USDT———TON / USDT———AVAX / USDT———LINK / USDT———ADA / USDT———TRX / USDT———DOT / USDT———
料金

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.