today i would like to share with you little more information about one of special indicator, which is not so well known,
but it can have interesting potencial for you.
Its called ALMA.
In the fast-paced arena of forex scalping, standard moving averages force a frustrating compromise: you either get rapid signals full of false breakouts (EMA) or smooth lines that lag terribly (SMA). The Arnaud Legoux Moving Average (ALMA) engineers a highly effective way out of this trap.
Developed by Arnaud Legoux and Dimitris Kouzis-Loukas, ALMA borrows signal-processing techniques to apply a Gaussian (bell curve) weight distribution to price data. It essentially filters price action from left to right and right to left, virtually eliminating the phase shift (lag) while ironing out the micro-noise that whipsaws short-term traders. For M1 or M5 scalpers, ALMA acts as an exceptionally clean dynamic support and resistance level. Its behavior is governed by three primary parameters:Window: The lookback period (e.g., 9 for rapid scalping). Offset: Dictates responsiveness on a scale of 0 to 1. Pushing it to 0.85 heavily weights the curve toward the most recent prices, allowing the line to tightly hug the trend. Sigma: Controls the Gaussian curve's width. A standard setting of 6 (inspired by the Six Sigma process) keeps the distribution crisp.
When the ALMA line slopes sharply, it confirms pure momentum. When price pulls back to the ALMA during an established micro-trend, it often presents a high-probability entry point. By stripping out market noise without delaying the signal, ALMA gives scalpers one of the clearest reads on immediate price action.
Custom ALMA Indicator for MT4 (MQL4)
Here is a lightweight, optimized MQL4 custom indicator script. You can compile this directly in MetaEditor and drop it into your platform's Indicators folder.
Code: Select all
//+------------------------------------------------------------------+
//| ALMA.mq4 |
//| Arnaud Legoux Moving Average |
//+------------------------------------------------------------------+
#property copyright "Custom Indicator"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 clrDodgerBlue
#property indicator_width1 2
input int Window = 9; // Window size
input double Offset = 0.85; // Gaussian Offset (0 to 1)
input double Sigma = 6.0; // Curve width
double ALMABuffer[];
int OnInit() {
SetIndexBuffer(0, ALMABuffer);
SetIndexStyle(0, DRAW_LINE);
IndicatorShortName("ALMA(" + IntegerToString(Window) + ")");
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[]) {
if (rates_total < Window) return(0);
int limit;
// Determine how many bars to calculate
if (prev_calculated == 0) {
limit = rates_total - Window + 1;
} else {
limit = rates_total - prev_calculated + 1; // Always recalculate the current active bar
}
double m = Offset * (Window - 1);
double s = Window / Sigma;
// Safeguard against division by zero
if (s == 0) s = 0.000001;
// Loop through chart bars
for (int i = 0; i < limit; i++) {
double wtdSum = 0.0;
double cumWt = 0.0;
// Apply Gaussian weighting over the Window
for (int k = 0; k < Window; k++) {
double wtd = MathExp(-MathPow(k - m, 2) / (2 * s * s));
// Close[] is an MT4 predefined timeseries array (0 is the current bar)
wtdSum += wtd * Close[i + Window - 1 - k];
cumWt += wtd;
}
if (cumWt > 0) {
ALMABuffer[i] = wtdSum / cumWt;
}
}
return(rates_total);
}
//+------------------------------------------------------------------+