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

Standard Deviation

Raw volatility measure behind the bands — MT4, MT5, TradingView and TradeStation code.

Standard deviation measures how far price disperses from its N-bar mean — the raw statistical building block behind volatility bands. Rising values warn of expanding volatility (bigger risk, smaller position sizing); low, contracting readings often precede breakouts. Copy the version for your platform.

Pine Script
//@version=5
indicator("Standard Deviation", overlay=false)
length = input.int(20, "Length")
dev = ta.stdev(close, length)
plot(dev, title="StdDev", color=color.navy, linewidth=2)
MQL4 · StdDev.mq4
#property indicator_separate_window
#property indicator_buffers 1

extern int Dev_Period = 20;
double DevBuffer[];

int OnInit() {
  SetIndexBuffer(0, DevBuffer);
  return 0;
}

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

input int Dev_Period = 20;
double DevBuffer[];

int OnInit() {
  SetIndexBuffer(0, DevBuffer);
  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++)
    DevBuffer[i] = iStdDev(NULL, 0, Dev_Period, 0, MODE_SMA, PRICE_CLOSE, i);
  return rates_total;
}
EasyLanguage
inputs: Length(20);
variables: Dev(0);
Dev = StandardDev(Close, Length, 1);
Plot1(Dev, "Standard Deviation");

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