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———
मूल्य निर्धारण

ATR (Average True Range)

Volatility gauge for sizing stops and positions — TradeStation, MetaStock and MT5 code.

ATR averages the true range (the largest of high–low, high–prevclose and low–prevclose) over N bars. It measures how much an instrument typically moves per bar, so traders size stops and positions to current volatility instead of a fixed number of pips. Copy the version for your platform.

EasyLanguage
inputs: Length(14);
variables: MyATR(0);
MyATR = AvgTrueRange(Length);
Plot1(MyATR, "ATR");
MetaStock
{ATR - Average True Range, period 14}
atrVal := ATR(14);
atrVal
MQL5 · ATR.mq5
#property indicator_separate_window
#property indicator_buffers 1

input int ATR_Period = 14;
double AtrBuffer[];

int OnInit() {
  SetIndexBuffer(0, AtrBuffer);
  IndicatorSetString(INDICATOR_SHORTNAME, "ATR(" + IntegerToString(ATR_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++)
    AtrBuffer[i] = iATR(NULL, 0, ATR_Period, i);
  return rates_total;
}

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

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