I remember when I first started Studying Forex Trading and short after I decided that I wanted to automate my trading as much as possible.
The idea of being influenced by emotion, the stress of seeing a position in loss and the greed of not closing a profitable trade…
Also, the problem of constantly having to monitor the positions… No Thanks!
A Trading Robot is much better than me at trading, it follows the rules, day and night, loss or profit.
Entry Signal Found? Entry! Exit Signal Found? Exit! As Easy As That!
Initially it was very challenging, it is another way of thinking and you need to translate everything into mathematical formulas, comparisons and break down complex problems into a sequence of simple actions.
After years of coding I accumulated a good amount of functions and routines that help me daily in the development of EAs and Indicators.
The MT4 Expert Advisor Template is the basic template for the development of my trading bots.
It includes the basic workflow and functions of a trading expert advisor WITHOUT entry and exit signals.
You can add your own entry and exit signals and run it.
I can guarantee this source code will significantly reduce the time you spend developing an Expert Advisor.
What Is MT4 Expert Advisor Template
MT4 Expert Advisor Template is 700+ lines of commented source code that you can use to build your own EA.
The code is explained so you can understand it’s logic.
You can customise portions of the code to achieve your entry and exit signal and have an EA ready to use.
What Does MT4 Expert Advisor Template Include
What MT4 Expert Advisor Template IS NOT
MT4 Expert Advisor Template IS NOT a fully automated strategy.
Although we include some automated bots to download with this template, these are only to show the potential of the code and as examples.
You will need to add to the template your own Entry and Exit signal code in order to have it fully operational.
Why Using MT4 Expert Advisor Template
What Is The Logic Of An Expert Advisor
All EA are divided in 3 main functions:
- OnInit is the initialization of the EA, the first function that runs when you load an EA
- OnTick runs every time MT4 receives a new quote for the current instrument
- OnDeinit runs just before closing the EA
Modules Included In MT4 Expert Advisor Template
MT4 Expert Advisor Template is written in a modular way so that all the functions are separate.
This allows to have a source code easier to read and to understand and also makes it easier to customise the code.
Here you see how the functions are separated in the execution.
What Do You Need To Use MT4 Expert Advisor Template
Although most of the code is provided and commented, you need to be able to add your own code for the Entry and Exit signal and if you want to customise Trailing Stop and Dynamic Stop and Take Profit.
I provide some examples together with the code and in my blog articles.
The files included to download are for the MT4 platform and only work on the MT4 platform.
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 to a working EA through the platform.
I would like to remind that this is not a fully working trading strategy.
You will have to include your own entry and exit signals and strategy.
From The Source Code
These are some extracts from the code.
This is a good way to understand if the product 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 see how the code for an Expert Advisor 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 is not something for you.
If you are interested in a more basic course to start programming in MQL4 let me know and I will put together a beginner course.
How To Install MT4 Expert Advisor Template
- Download The Files
- Open the MQL4 Folder, from MT4 Client click File -> Open Data Folder
- Copy the .mqh file in the Include folder
- Copy the icon in the Files folder
- Copy the .mq4 files in the Experts folder
- Open the files with Metaeditor
How To Use It
Customise the following functions in order to complete the signals:
- EvaluateEntry contains the code to trigger an entry signal, it is necessary to add something here
- EvaluateExit contains the code to trigger the exit signal, you can leave this as is if you use fixed stop loss and take profit
- ExecuteTrailingStop contains the code to trail the stop loss, necessary only if you want to add a trailing stop function
- StopLossPriceCalculate contains the code to assign a dynamic value to the stop loss, not mandatory
- TakeProfitPriceCalculate contains the code to assign a dynamic value to the take profit, not mandatory