Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

DailyHighLow Indicator for MQL5 - MetaTrader 5 Script - MT4/MT5 Resources

author EAcpu | 6 reads | 0 comments |

DailyHighLow Indicator for MQL5 - indicator for MetaTrader 5

DailyHighLow Indicator for MQL5 - indicator for MetaTrader 5

DailyHighLow Indicator for MQL5 - indicator for MetaTrader 5

DailyHighLow Indicator for MQL5 - indicator for MetaTrader 5

The indicator draws two lines on the chart: one representing the highest price and the other representing the lowest price, calculated based on user-defined inputs. Its main features include:

Customizable time range : The user can select a time range (e.g. daily, hourly) using the following options . Approximate time input, default is PERIOD_D1 (daily). This indicator ensures that the selected time range is no smaller than the current time range of the chart to maintain data accuracy.

Price calculation options : This price input allows the user to choose between three modes:

Low/High (DHL_LOWHIGH) : Plots the highest and lowest price within the specified time range.

Open/Close (DHL_OPENCLOSE) : Draw the maximum value of the opening price/closing price and the minimum value of the opening price/closing price.

Close/Close (DHL_CLOSECLOSE) : Plots the highest and lowest closing prices.

Previous period option : This previous input (default: true ) allows the user to display the previous period's highs/lows, aiding in historical analysis.

Visual customization : The indicator uses solid silver lines with a width of 1 for both high and low charts, ensuring clear visibility without cluttering the chart.

The indicator operates by initializing two buffers ( high buffer and low buffer ) to store and displays the highest and lowest price levels. During initialization ( when initializing ), it sets these buffers and validates the time range. The core logic lies in the calculation time function, which processes the price data of each bar:

Data preparation : The arrays of time, opening price, closing price, highest price and lowest price are set as reverse-indexed series.

Time frame adjustment : The indicator calculates bar changes using iBarShift to align the data to the selected time frame.

Price calculation :

For DHL_LOWHIGH , it directly uses love high and low to get high and low prices.

For DHL_OPENCLOSE and DHL_CLOSE closures , it uses the following method to determine the highest/lowest opening price or the highest and lowest closing price within the time range.

Pre-processing : If previously enabled, calculations will be moved to pre-processing, providing historical context.

Optimization : The indicator limits calculations to new or updated bars ( limits ) to guarantee efficiency and avoid redundant processing.

The Daily High and Low indicator is ideal for traders employing strategies based on key price levels, such as:

Support & Resistance : Identify high/low levels on a daily or custom timeframe for breakout or reversal strategies.

Trend Analysis : Compares current price action to previous highs/lows to determine market direction.

Risk Management : Set stop loss or take profit levels based on important price points.

Installation : Add indicators to your MetaTrader 5 platform by copying the code to the MQL5/Indicators folder and compiling.

Set the desired approximate time (e.g., PERIOD_D1 daily level).

Choose a price mode ( DHL_LOWHIGH , DHL_OPENCLOSE , or DHL_CLOSE OFF ) based on your strategy.

Enables or disables the previous option to switch between current and previous period data.

Chart App : Attach indicators to any chart. It will show two silver lines representing the highest and lowest prices.

This Daily High and Low indicator is a simple yet powerful tool for MQL5 traders, offering flexibility in terms of timeframe and price calculation method. Its lightweight design and efficient processing make it suitable for both novice and experienced traders looking to enhance their technical analysis.

If you have suggestions or encounter problems, please leave a comment on the MQL5 code base page or contact me By MQL5 Community. Your feedback is very valuable to improve this tool!


Contact me: MQL5 link


Attachment download

📎 dailyhighlow_indicator.mq5 (4.48 KB)

Source: MQL5 #59477

Verification code Refresh