4/4/25, 2:35 PM Alert Indicator Template for MT4
EN
Advertisements
— AvexBot GBPUSD, Growth Ahead!
— Trade Forex with 1:2000 Leverage
EarnForex Software MetaTrader Indicators Alert Indicator Template for MT4
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.
Table of contents
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 1/12
4/4/25, 2:35 PM 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.
Table of contents
Ready-to-use alerts.
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 2/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
Simplicity in development.
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.
Table of contents
Why Use MT4 Alert Indicator Template?
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 3/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
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.
Table of contents
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 4/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
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.
/*
CUSTOMIZE THE FOLLOWING TO GET YOUR OWN INDICATOR UP AND RUNNING
1) Add to the INPUT PARAMETERS the parameters you need for your signal, this can be a period
2) Add some requirement checks in OnInitPreChecksPass if it is necessary to check the consist
3) Define in the IsSignal function at the end of the code the rule for your signal
Table of contents
*/
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 5/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
//-PROPERTIES-//
//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 "https://www.earnforex.com/metatrader-indicators/alert-indicator-tem
#property version "1.0"
#property strict
#property copyright "EarnForex.com - 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 dam
#property description " "
#property description "Find More on EarnForex.com"
//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 comm
#property icon "\\Files\\EF-Icon-64x64px.ico"
//-INPUT PARAMETERS-//
//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 t
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
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 (Minute
//Arrow Style can be chosen between Wingdings and preset arrows, see following URLs for all t
Table of contents
//https://docs.mql4.com/constants/objectconstants/wingdings
//https://docs.mql4.com/constants/objectconstants/arrows
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 6/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
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 Cand
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
//it can return SIGNAL_BUY=1, SIGNAL_SELL=-1,SIGNAL_NEUTRAL=0
//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 yo
int j=i+Shift;
//Initialize the Signal to a neutral/stop one
ENUM_TRADE_SIGNAL Signal=SIGNAL_NEUTRAL;
//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 vari
//Define the condition for your sell signal
Table and assign SIGNAL_SELL value to the Signal va
of contents
//Define the condition for your stop/neutral signal and assign SIGNAL_NEUTRAL value to the
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 7/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
//Defining a stop/neutral condition is not always necessary, many systems work with only
//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.
Downloads
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. Table of contents
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 8/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
➥ MQLTA MT4 Alert Indicator Template
Download
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.
Subscribe to the newsletter
We’ll send you our monthly newsletter which is fully stocked with free resources like articles,
videos, podcasts, reward ideas, and anything else we can think of to help you make your
trading knowledge awesome. Table of contents
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 9/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
Enter your email address
SUBSCRIBE TO OUR NEWSLETTER
Advertisements
— Trade smarter: TradingView, MT4, MT5.
Forex — the foreign exchange market (also known as FOREX or FX) is the biggest and the most liquid financial market in the
world. It boasts a daily volume of more than $7.5 trillion. Trading in this market involves buying and selling world currencies,
taking profit from the exchange rates difference. FX trading can yield high profits but is also a very risky endeavor.
Forex Brokers
MT4 Forex Brokers
MT5 Forex Brokers
PayPal Brokers
Regulated Brokers
Oil Trading Brokers
Gold Trading Brokers
Muslim-Friendly Brokers
Web Browser Platform
Brokers with CFD Trading
ECN Brokers
Skrill Brokers
Neteller Brokers
Perfect Money FX Brokers
See all Table of contents
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 10/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
Forex Tools
Forex Brokers
Community
Forex Books
Software
Education
About
© 2005-2025. EarnForex. All Rights Reserved.
Developed by
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
Table of contents
carry a high level of risk thus may not be appropriate for all investors. EarnForex.com is operated by EARNFOREX S.A.S., a
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 11/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
company registered at the following address: 229 rue Saint-Honoré, 75001 Paris, France. Tribunal de commerce de Paris
registration number: 951833029. French VAT ID: FR04951833029.
Table of contents
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 12/12