Alert Indicator Template for MT4
Alert Indicator Template for MT4
EN
Advertisements
— AvexBot GBPUSD, Growth Ahead!
— Trade Forex with 1:2000 Leverage
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
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.
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.
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
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.
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
MT4 platform — the files included in the download are for MetaTrader 4 and will only work in the MT4
platform.
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
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
ENUM_CANDLE_TO_CHECK CandleToCheck=CURRENT_CANDLE; //Candle To Use For Analysis
//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
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 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
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.
Downloads
You can download the indicator for free using the link below and install it by following the provided
instructions.
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 8/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
Download
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.
https://www.earnforex.com/metatrader-indicators/alert-indicator-template/ 9/12
4/4/25, 2:35 PM Alert Indicator Template for MT4
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
PayPal Brokers
Regulated Brokers
Muslim-Friendly Brokers
ECN Brokers
Skrill Brokers
Neteller Brokers
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
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