Alert Indicator Template for MT4

When traders start studying Forex trading, they soon come to a decision that it is better to automate the trading process as much as possible. In our days, computers can provide a great help in trading system development and implementation.

When you are developing a trading system and looking for possible entry and exit rules it is very useful to see a visual representation of when these rules would be applied.

At the same time, if you already have a working trading system, you don't want to miss any trades and you want to get alerts when your entry or exit signals appear.

Alert Indicator Template is the basic template that was used for the development of our MT4 alert indicators.

It includes the basic workflow and functions of an indicator without entry and exit signals.

You can add your own entry and exit signals and run it.

This source code will significantly reduce the time you spend developing an alert indicator.

About Alert Indicator Template for MT4

What Is MT4 Alert Indicator Template?

MT4 Alert Indicator Template is 400+ lines of commented source code that you can use to build your own indicator with alerts.

The code is thoroughly explained so that you could easily understand its logic.

You can customize portions of the code to achieve your entry and exit signals and have an indicator ready to use.

What Does MT4 Alert Indicator Template Include?

  • Comments for each function to understand the code's logic.
  • Well-written code.
  • Modular structure.
  • Ready-to-use alerts.
  • Simplicity in development.

Alert Indicator Template for MT4 - Input Parameters

What MT4 Alert Indicator Template Is Not?

MT4 Alert Indicator Template is not a fully automated strategy.

Although it includes some finished examples to download with this template, they are only to show the potential of the code.

You will need to add your own entry or exit signals code to the template in order to have it do something useful.

Why Use MT4 Alert Indicator Template?

  • Alert notifications — you can easily create your custom indicator to get alerts on screen, mobile, and email.
  • Save time — save many hours of research and coding using ready-made functions.
  • Visual representation — you can quickly see if your entries and exits have an edge in the market.
  • Easy-to-edit — with only a few lines of code, you can develop your own indicator and have a fully automated generation of trading signals.

What Is the Indicator's Logic?

All indicators are divided into three main functions:

  1. OnInit() is the initialization of the indicator, the first function that runs when you load it.
  2. OnCalculate() runs every time MT4 receives a new quote for the current instrument.
  3. OnDeinit() runs just before the indicator is removed from the chart or the chart is changed.

MT4 Alert Indicator Template is written in a modular way so that all the functions are separate. This allows you to have a source code that is easy to read and to understand and also makes it easier to customize the code.

What Do You Need to Use MT4 Alert Indicator Template?

Basic knowledge of MQL4 programming — although most of the code is provided and commented, you need to be able to add your own code for entry and exit signals.

MT4 platform — the files included in the download are for MetaTrader 4 and will only work in the MT4 platform.

Understanding of compiling — it is advisable to be familiar with compilation, which is understanding that this product is source code to be edited in the MetaEditor and compiled into a working indicator through it.

Willingness to experiment — this is not a fully working trading strategy and requires some creative work to become a usable indicator. You will have to include your own entry and exit signals and strategy.

Source Code

These are some extracts from the code. This is a good way to understand if this template is suitable for you.

If what you see makes sense then I am sure it will significantly help you. If it doesn't make sense but you are interested in seeing how the code for an alert indicator works, then this can help you.

If you are not the coding type of person and all this doesn't interest you, then probably this template isn't something you need.



1) Add to the INPUT PARAMETERS the parameters you need for your signal, this can be a period for the RSI or Moving Average, the step for a PSAR and so on

2) Add some requirement checks in OnInitPreChecksPass if it is necessary to check the consistency of the parameters

3) Define in the IsSignal function at the end of the code the rule for your signal


//Properties help the software look better when you load it in MT4
//Provide more information and details
//This is what you see in the About tab when you load an Indicator or an Expert Advisor
#property link          ""
#property version       "1.0"
#property strict
#property copyright     " - 2019-2021"
#property description   "Alert Indicator Template"
#property description   "So You Can Create Your Own Indicator And Alerts"
#property description   " "
#property description   "WARNING : You use this software at your own risk."
#property description   "The creator of these plugins cannot be held responsible for any damage or loss."
#property description   " "
#property description   "Find More on"
//You can set an icon for the indicator to show when loading it on chart
//Icon must have an ico extension and be located in the MQL4/Files folder, the following commented line is an example of icon
#property icon          "\Files\EF-Icon-64x64px.ico"
//The input parameters are the ones that can be set by the user when launching the Indicator
//If you place a comment following the input variable this will be shown as description of the field

input string Comment1="========================";     //MQLTA Alert Indicator Template
input string IndicatorName="MQLTA-AIT";               //Indicator Short Name

input string Comment2="========================";     //Indicator Parameters
//This is likely the only section you need to edit to adapt the indicator to your goal
//For example if you are using RSI in you indicator you can add here the input for the period and the relevant levels

input ENUM_CANDLE_TO_CHECK CandleToCheck=CURRENT_CANDLE;    //Candle To Use For Analysis
input int BarsToScan=500;                                   //Number Of Candles To Analyse

input string Comment_3="====================";     //Notification Options
input bool EnableNotify=false;                     //Enable Notifications Feature
input bool SendAlert=true;                         //Send Alert Notification
input bool SendApp=true;                           //Send Notification to Mobile
input bool SendEmail=true;                         //Send Notification via Email
input int WaitTimeNotify=5;                        //Wait time between notifications (Minutes)

//Arrow Style can be chosen between Wingdings and preset arrows, see following URLs for all the codes
input string Comment_4="====================";     //Buffers Options
input int ArrowTypeBuy=241;                        //Code For Buy Arrow
input int ArrowTypeSell=242;                       //Code For Sell Arrow
input bool ArrowShowNeutral=false;                 //Show Stop Arrow
input int ArrowTypeStop=251;                       //Code For Stop Arrow
input color ArrowColorBuy=clrGreen;                //Color For Buy Arrow
input color ArrowColorSell=clrRed;                 //Color For Sell Arrow
input color ArrowColorStop=clrGray;                //Color For Stop Arrow
input ENUM_CANDLE_SIZE ArrowSize=CANDLE_SIZE_MEDIUM;    //Size Of The Arrows
input ENUM_CANDLE_DISTANCE CandleDistance=CANDLE_DISTANCE_NEAR;    //Arrow Distance From Candle

How to Use Template?

Customize the following functions in order to complete the development of the signals:

  • Add the input parameters for your entry or exit.
  • OnInitPreChecksPass() function contains the code to check the validity of the input parameters — you can add your checks here.
  • Add your data to evaluate and the entry/exit rules to the IsSignal() function.
//The IsSignal function is where you check if the candle of index i has a signal
//This functions is where you define your signal rules
ENUM_TRADE_SIGNAL IsSignal(int i){
   //Define a variable j which is the index of the candle to check, this is to consider if you are checking the current candle or the closed one
   int j=i+Shift;
   //Initialize the Signal to a neutral/stop one
   //Define all the values that you are going to need to check your signal rules first
   //Define the condition for your buy signal and assign SIGNAL_BUY value to the Signal variable if the condition is true
   //Define the condition for your sell signal and assign SIGNAL_SELL value to the Signal variable if the condition is true
   //Define the condition for your stop/neutral signal and assign SIGNAL_NEUTRAL value to the Signal variable if the condition is true
   //Defining a stop/neutral condition is not always necessary, many systems work with only Buy and Sell
   //Return the Signal and exit the function
   return Signal;

Fully Working Examples Provided

Together with the template, you also download seven fully functional alert indicators built upon the code, so you would see how the template can been customized in practice.

Currently, the following examples are included:

  • Box Breakout Alert — to alert if the price breaks out of the recent highs or lows.
  • MA Crossover — to alert if two moving averages cross.
  • MACD Cross — to alert if the MACD line crosses the zero line.
  • RSI Overbought/Oversold — to alert if RSI reached an overbought or oversold state.
  • RSI Reversal to Range — to alert if RSI returns to the middle.
  • Stochastic + MA — a composite indicator that alerts a compound alert based on MA and Stochastic.
  • Bollinger Bands Breakout — to alert if the price breaks out of the bands.

How to Download MT4 Alert Template Indicator

You can download the indicator for free using the link below and install it by following the provided instructions.

The installation is very easy to perform.

➥ Download MQLTA MT4 Alert Indicator Template

MT4 Alert Template Indicator Installation

To install MT4 Alert Template Indicator, please follow the instructions below:

  1. Download the indicator archive file.
  2. Open the MetaTrader 4 data folder (via File→Open Data Folder).
  3. Open the MQL4 Folder.
  4. Copy all the folders from the archive directly to the MQL4 folder.
  5. Restart MetaTrader 4 or refresh the indicators list by right-clicking the Navigator subwindow of the platform and choosing Refresh.

For more detailed instructions on how to perform the installation please visit this article.

You can open a trading account with any of the MT4 Forex brokers to freely use the presented here indicator for MetaTrader 4.

© 2005–2023

Design — Mart Studio

Forex trading bears intrinsic risks of loss. You must understand that Forex trading, while potentially profitable, can make you lose your money. Never trade with the money that you cannot afford to lose! Trading with leverage can wipe your account even faster.

CFDs are leveraged products and as such loses may be more than the initial invested capital. Trading in CFDs carry a high level of risk thus may not be appropriate for all investors.