MQL4 Low Function Guide Learn MT4 Candlestick Syntax

Updated: 2025/11/25  |  CashbackIsland

Ultimate Guide to the MQL4 Low Function: One Article to Understand MT4 Candlestick Low-Point Syntax for Algorithmic Trading

mql4-low-function-guide

Want to develop your own trading indicators or EAs in MT4 but always get stuck on how to capture the lowest price of a candlestick? The MQL4 Low function is the key to achieving this, yet its usage and its difference from “iLow()” often confuse beginners. This article will guide you from zero, thoroughly explaining the core syntax for obtaining MT4 candlestick lows and providing practical examples to help you easily master this essential MT4 algorithmic trading syntax skill and take the first step toward automated trading.

 

What Is the MQL4 Low Function? Mastering the Core of MT4 Candlestick Low Points

In the MQL4 language, `Low` is not a traditional “function”, but a predefined time series array. You can think of it as a container filled with historical price data, specifically storing the lowest price of each candlestick. This array is built into MQL4 and can be used directly in your indicator, EA (Expert Advisor), or script without any additional declaration.

 

Low[]: Definition and Syntax of the Predefined Time Series Array

The syntax of the `Low[]` array is very straightforward. It uses an index value to access the lowest price of a specific candlestick. This index begins at 0 and represents different points in time:

  • `Low[0]`: The lowest price of the current (newest) forming candlestick.
  • `Low[1]`: The lowest price of the previous closed candlestick.
  • `Low[2]`: The lowest price of the candlestick two bars ago.
  • `Low[n]`: The lowest price of the candlestick n bars ago.

This array stores price data in `double` format. For example, if you want to declare a variable to store the previous candlestick’s low, you can write:

double previousBarLow = Low[1];

Understanding this indexing rule is fundamental in learning MQL4 algorithmic trading syntax, because the same logic applies to other time series arrays such as `Open[]`,  `High[]`,  `Close[]`, and `Volume[]`.

 

How to Read the Low of Different Candlesticks? (Current, Previous, N Bars Ago)

Accessing the lowest price of different candlesticks is very simple, you only need to change the index value inside the brackets `[]`. Here are some common examples:

  • Read the current candlestick’s live lowest price:
    `double currentLow = Low[0];`
    Note: This value will change in real time with market prices until the candlestick closes.
  • Read the previous candlestick’s fixed lowest price:
    `double lastClosedLow = Low[1];`
    This value is fixed because the candlestick has already closed and will no longer change.

Use a loop to read the lows of the last 10 candlesticks:
for(int i = 1; i <= 10; i++)

{

Print(“The lowest price of the candlestick “, i, ” bars ago is: “, Low[i]);

  • }

This code prints the lowest price of each candlestick from the most recently closed bar going back 10 bars.

 

Practical Examples and Source Code for the MQL4 Low Function

Now that the theory is clear, let’s move on to real application! After understanding the MT4 lowest-price indicator syntax, you can apply it to many trading strategies. Below are several practical examples to help you better understand how to use the `Low` array in real trading scenarios.

 

Example 1: Mark the Lowest Point of the Past 20 Candlesticks on the Chart

This simple indicator draws a small arrow at the lowest price of each candlestick, allowing you to visually identify recent support levels. This is very useful for observing price action or identifying potential entry points.

//+——————————————————————+

//|                                            MarkLowestPoints.mq4 |

//|                        Copyright 2025, CashbackIsland           |

//+——————————————————————+

#property copyright “Copyright 2025, CashbackIsland”

#property link      “”

#property version   “1.00”

#property strict

#property indicator_chart_window

 

#property indicator_buffers 1

#property indicator_color1  clrGold

 

//—- indicator buffers

extrn int LookbackPeriod = 20; // Set the number of candlesticks to mark

double ArrowBuffer[];

 

//+——————————————————————+

//| Custom indicator initialization function                         |

//+——————————————————————+

int OnInit()

  {

//—- indicator buffers mapping

   SetIndexBuffer(0, ArrowBuffer);

   SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 2);

   SetIndexArrow(0, 233); // Set the arrow style

   SetIndexLabel(0, “Lowest Point”);

 

//—- initialization done

   return(INIT_SUCCEEDED);

  }

//+——————————————————————+

//| Custom indicator iteration function                              |

//+——————————————————————+

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[])

  {

//—-

   int limit = rates_total – prev_calculated;

   if(prev_calculated > 0) limit++;

 

   for(int i = 0; i < limit && i < LookbackPeriod; i++)

     {

ArrowBuffer[i] = Low[i]; // Place the arrow at the candlestick’s lowest price

     }

//—- return value of prev_calculated for next call

   return(rates_total);

  }

//+——————————————————————+

 

Example 2: Write a Simple “Break Below Low” Alert Indicator

Many trading strategies are based on price breakouts. For instance, when the price falls below the previous candlestick’s low, it may be a bearish signal. The following source code will trigger a pop-up alert when the price breaks below the previous low.

// Simple breakout alert EA example (place inside the OnTick() function)

void OnTick()

{

// Use a static variable to ensure the alert is sent only once

   static datetime lastAlertTime = 0;

 

// Get the current price and the previous candlestick’s low

double currentPrice = Bid;

double previousLow = Low[1];

 

// Check the condition: current price breaks below the previous low,

// and the alert has not been triggered within the current candlestick

if(currentPrice < previousLow && Time[0] != lastAlertTime)

{

   Alert(“Price Alert: “, Symbol(), ” current price “, currentPrice,

         ” has broken below the previous low “, previousLow, “!”);

   lastAlertTime = Time[0]; // Update alert time to avoid repeated triggers

}

}

 

Combining Other MQL4 Syntax: Calculating Candlestick Body and Wick Lengths

Once you have mastered `Low[]`, you can combine it with `High[]`, `Open[]`, and `Close[]` to perform deeper candlestick analysis. For example, calculating the length of the lower wick is very useful when assessing buying support strength in the market.

  • Candlestick body (Body) length: `MathAbs(Open[i] – Close[i])`
  • Upper wick length: `High[i] – MathMax(Open[i], Close[i])`
  • Lower wick length: `MathMin(Open[i], Close[i]) – Low[i]`

By analyzing these values, you can develop more complex trading logic, such as a strategy that “goes long when a hammer candle with a long lower wick appears”. If you want to learn more introductory concepts about MQL4, you can refer to the relevant teaching guides.

 

Advanced Technique: Comparison and Application of Low[] vs. iLow() Functions

Once you have a basic understanding of the MQL4 Low function, you will soon encounter its “sibling” function `iLow()`. Although both can obtain the lowest price, their use cases and functionalities are vastly different. Understanding their differences is an important step in moving from a beginner to an advanced developer.

 

Differences in Functionality: Current Chart vs. Specified Symbol and Timeframe

The core difference between the two lies in the flexibility of their data sources:

  • `Low[]` array:

    • Advantages: Simple, fast, and intuitive.
    • Limitation: It can only read data from the symbol and timeframe of the current chart. For example, if your indicator is placed on an EURUSD H1 chart, `Low[]` can only access the lows of EURUSD H1 and cannot retrieve information from other symbols or timeframes.
  • `iLow()` function:

 

  • Advantages: Highly versatile and powerful.
  • Syntax: `double iLow(string symbol, int timeframe, int shift);`
  • Function: It can retrieve the lowest price of any specified symbol on any timeframe. For example, even if you are on an EURUSD H1 chart, you can still use `iLow(“GBPUSD”, PERIOD_D1, 1)` to obtain the previous candlestick’s low on the GBPUSD daily chart.

 

Scenario Analysis: When Should You Use Each One? 

Choosing between `Low[]` and `iLow()` depends entirely on the needs of your strategy:

✅ Use `Low[]` when:

  • Your strategy analyzes only the current chart and does not involve multi-symbol or multi-timeframe logic.
  • You need the fastest possible data access (because `Low[]` is preloaded and slightly faster than `iLow()`).
  • You want clean and readable source code, such as when writing a simple moving average indicator.

✅ You should use `iLow()` when:

  • You need to develop a multi-currency hedging EA, such as monitoring both EURUSD and USDCHF simultaneously.
  • Your strategy involves multi-timeframe analysis, such as referencing the D1 support level while working on an H1 chart (`iLow(Symbol(), PERIOD_D1,1`)).
  • You need to access data from non-standard timeframes (such as H2 or M10).

In summary, `Low[]` solves “current” chart needs, while `iLow()` solves “any” chart needs. For beginners, mastering `Low[]` first and then gradually exploring the powerful capabilities of `iLow()` is a more stable learning path. If you are interested in developing more advanced EA trading systems, `iLow()` will be an indispensable tool.

 

Common Questions (FAQ)

Q: Does MQL4 Low[0] return a live-updating price?

A: Yes. `Low[0]` represents the lowest price of the current candlestick (which has not yet closed). As long as new tick data arrives, this value will update accordingly. Once the candlestick closes, the value of `Low[0]` becomes fixed and will shift to `Low[1]` when a new candlestick forms.

Q: How do I find the lowest price among the past N candlesticks?

A: You need to loop through the `Low[]` array. You can simplify the process by using the built-in MQL4 `Lowest()` function. For example, to find the lowest price among the past 20 candlesticks starting from the previous bar, you can write: `int lowestBarIndex = Lowest(NULL, 0, MODE_LOW, 20, 1);` This returns the index of the candlestick that contains the lowest price, and you can then obtain that value using `Low[lowestBarIndex]`.

Q: Is there any difference when using the Low function in a Script versus an EA (Expert Advisor)?

A: Functionally, there is no difference, but the execution logic is not the same. A script typically runs only once and then stops, so the `Low` values it reads are merely a snapshot of that moment. An EA, however, runs continuously inside the `OnTick()` function. Each time new market data arrives, `OnTick()` is triggered, allowing the EA to continuously obtain the latest `Low[0]` price for real-time decision-making.

Q: What happens if historical data on the chart is insufficient and you try to read Low[1000]?

A: If the index exceeds the amount of historical data currently loaded on the chart, reading `Low[i]` will return either 0 or an invalid value. When processing loops, it is best practice to check how many candlesticks the chart contains using variables such as `Bars` or `rates_total` to avoid accessing invalid data. This is an important habit in proper program design.

 

Conclusion

In summary, the `MQL4 Low` function (or more precisely, the `Low[]` array) is a fundamental tool that every MT4 algorithmic trading developer must master. Through this article, you have learned its basic syntax, how to read the lowest prices of candlesticks across different periods, practical application examples, and the key differences between Low[] and `iLow()`. Mastering the core syntax of MT4 lowest-price indicators is not difficult; the key lies in understanding the indexing logic behind them and practicing consistently. Now is the time to open your MetaEditor, review the official MQL4 documentation, and start writing your first indicator or trading strategy!


If you liked this article, please share it!

Related Articles

  • Volatility Surface Guide: Skew Trading Strategies
    Practical Applications of Volatility Surfaces: From Options Modeling to Advanced Skew Trading Strategies In options markets, implied volatility is never a flat line. Instead, it forms complex "smile" or "skew" surfaces. For advanced traders, mastering the practical applications of volatility surfaces is equivalent to possessing a lens that reveals market...
    2026 年 6 月 3 日
  • Foreign Capital Flow Model: Track Institutional Money
    Building a Foreign Capital Flow Copy Trading Model: A Stock Market Indicator for Accurately Tracking Institutional Positioning In Asia-Pacific stock markets, foreign capital inflows and outflows often determine the direction of the index. However, simply looking at daily net buy and sell data is no longer enough. Only by building...
    2026 年 6 月 3 日
  • Options Buying Strategies for Extreme Market Risks
    Options Buyer Strategies During Extreme Market Conditions: Black Swan Hedging and Cross-Market Arbitrage During Volatility Surges The most terrifying aspect of financial markets is not a gradual decline, but overnight flash crashes and cross-market capital withdrawals accompanied by volatility surges. In the highly unpredictable global macroeconomic environment of 2026, geopolitical...
    2026 年 6 月 3 日
返回顶部