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%

WMA (Weighted Moving Average)

Recency-weighted moving average — MT4, MT5, TradingView, TradeStation and MetaStock code.

A weighted moving average weights recent bars more heavily than older ones (weights N, N−1, … 1), so it turns faster than a simple MA while staying smoother than an EMA. Traders use it as a responsive trend line and in fast/slow crossover systems. Copy the version for your platform.

Pine Script
//@version=5
indicator("Weighted Moving Average", overlay=true)
length = input.int(20, "Length")
wma = ta.wma(close, length)
plot(wma, title="WMA", color=color.green, linewidth=2)
MQL4 · WMA.mq4
#property indicator_chart_window
#property indicator_buffers 1

extern int WMA_Period = 20;
double WmaBuffer[];

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

int OnCalculate(const int rates_total, const int prev_calculated, const double &close[]) {
  for (int i = prev_calculated; i < rates_total; i++)
    WmaBuffer[i] = iMA(NULL, 0, WMA_Period, 0, MODE_LWMA, PRICE_CLOSE, i);
  return rates_total;
}
MQL5 · WMA.mq5
#property indicator_chart_window
#property indicator_buffers 1

input int WMA_Period = 20;
double WmaBuffer[];

int OnInit() {
  SetIndexBuffer(0, WmaBuffer);
  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++)
    WmaBuffer[i] = iMA(NULL, 0, WMA_Period, 0, MODE_LWMA, PRICE_CLOSE, i);
  return rates_total;
}
EasyLanguage
inputs: Length(20);
variables: MyWMA(0);
MyWMA = WAverage(Close, Length);
Plot1(MyWMA, "Weighted MA");
MetaStock
{Weighted Moving Average - period 20}
wma := Mov(C, 20, W);
wma

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

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