Learning To Write EA Part 1

The series is initially based on the MQL4 book which can be found at the mql4website. The book is an excellent source to start writing your traders and also a source of a decent amount of platform and market details. Having a bit of an idea about programming does help in getting more out of the book and it does require more than a couple of reads to make one comfortably started. So here, we will try to summarize certain items, ignore but mention in passing certain non critical parts for beginners and hope to save you time in the process.

The MQL4 language is similar to C++ apart from the object oriented part and the more pressing topics like pointers and structures. It allows you to write simple algorithms to make your ideas into auto traders. The benefits are many. Apart from having an auto trader, your strategy testing, data gathering and evaluation of new indicators become a breeze. Even for firm believers in manual trading, this cuts down time spent in exploring alternate methods and makes you aware of the potential risks of your strategy.

Now for the basics. The whole platform can be broken down into components shown in the picture below –


That is –

  1. Market – The actual transaction area.
  2. Dealing Centre  – The broker you have your account with.
  3. Metatrader 4 Client  – The screen you see in front of you.

The assumption here is that you are already familiar with the metatrader 4 platform.  The Dealing Centre here is your account provider –eg.  FXDD, Forex.com, DFT. Traders, indicators and scripts use the same interface i.e. Metatrader4 client to deal with the Dealing Centre. To familiarise yourself, look at the left hand side of the default client window. What you see is the navigator panel listing down all the EAs, scripts and indicators that you can use with your charts.


Dive straight in. Certain EAs like the Moving Average come pre-packaged and is highlighted in the picture above. Right Click on it and choose ‘Modify’. This will open up the MetaEditor. A fully self contained environment for development of the EA.


As shown above, all the code is in Editing Area. The File Explorer area shows you other kind of files available in the directory. The files with extension .mq4 are the code files. Now that you are introduced to the development area, lets do a couple of things to familiarize you more and shift to description of the code.



As shown above, go to the top of the editing area, make a change in the line highlighted making the DecreaseFactor 5 from original 3. Now choose File->Save As and save the modified file as “Moving Average Mod”. Press the ‘Compile’ button on the top. Now shift to the Metatrader 4 client and restart it. Look at the Navigator window again and you should see your modified EA just below ‘Moving Average’ called ‘Moving Average Mod’! Congratulations! you have your first EA. Not quite but now you are familiar with essentially what it takes.

To check the modification that you did. It is a minor one. Attach the EA to the chart by right clicking on it and choosing ‘Attach to a chart’. The window will pop up. Select the inputs tab and this is what you will see –


Look at the default value of DecreaseFactor. It is 5 as you changed. Perform the same on ‘Moving Average’ EA and you will see 3. With this, lets end todays familiarization lesson with creating a fresh blank EA. Go to the Metaeditor. Choose File->New. The following screen pops up –


Choose ‘Expert Advisor’, press ‘Next’. Insert ‘First’ in the name section and press ‘Finish’. The editor area will now contain a default template and is essentially blank. Press compile as before and exit the Metatrader4 client and start it again. You will see your blank EA in the ‘Navigator’ window.

That is it for this part. Next, we will try and learn the ever important ‘data types’ and see what we can do with that in the blank ‘First’ EA we created.

EA Builder

Share Button

Can You Trust Expert Advisors To Do Your Trading?

To trust or not to trust is the question.
You have to ask yourself this question, can you trust Expert Advisors to do your trading for you?
If you don’t know what is an expert advisor or trading robot, please check out this article about what is a Forex expert advisor.

I am an engineer by training and believe we should make use of technology and automation of some process to increase productivity and free yourself from some manual task that can be automated thus allocating more time for other tasks.

Understanding the Expert Advisor

Having said that, I’m a fan of automated trading with EAs (Expert Advisors) but not all EAs can be trusted before rigorous testing have been carried out and also a proper understanding of the strategy it’s programmed to trade and it’s algorithm.
Of course that may not be possible with some commercially purchased EA where you don’t have the trading algorithm and/or source code and even if you do and you don’t understand the code, it will still come to nothing.

Regardless of how automated your process can be, it still needs the human touch to turn it on/off and set the operating parameters and such. Leaving a robot on its own is not safe and will still need monitoring from time to time. Letting an EA run without monitoring can end up with empty account (EA).

No matter how prepared it is for all kinds of market condition as some claimed, there are always exception. There are times when certain market conditions that a robot cannot see or sense and will need human intervention to correct it.

Some will show you their expert advisor proven track record or back-testing with high accuracy for the past months or years, it doesn’t matter if the back-testing is done on live trading account or demo account.
I would like to point out that whatever the expert advisor had traded over the past minute, hour, days, weeks, months or years is still history once time has past.

And always remember past performance is not an indication of future results (I am sure you have seen many similar statements everywhere else). The Forex market is dynamic and volatile and unexpected things always happen from time to time. Some EA may work well in certain market condition but may not perform in all market condition.

So if you ask me, can you trust Expert Advisors to do your trading?

You have to monitor from time to time and may need to make make some decision along the way if it should be left on its own or to shut it down.

I have done a fair bit of testing of EAs and also know a bit of coding and my take is, I have yet to come across a full auto Forex expert advisor that can be trusted to run without monitoring and some human intervention.
Do your homework and understand what are the risks involved in using that EA. There are times when it’s better to shut your expert advisor down.

It can erase your account and I have personally seen it happened before to other people accounts.
So be warned! And always expect the unexpected.

In my opinion, a semi-auto expert advisor to help you place your order when the trading conditions are right would be a better option. But using a semi-auto Forex expert advisor means you have to be in front of your terminal to activate it and your emotions will come into play too when it’s time to pull the trigger.

Good luck and safe trade.

Share Button

Should You Buy Forex Expert Advisors To Trade?

To buy or not to buy, that is the question. Should you buy Forex expert advisors to trade Forex? I believe that is a question many of you may be asking yourself so I’m here to help with some suggestions.

There are many advantages of having Forex expert advisors to do trading on your behalf but with it, come many disadvantages too. This is especially true for those robots that you purchase.

There are many out Forex robots out there with new ones appearing almost everyday for $97 or thereabout, you can supposedly get the greatest and most profitable never seen before Forex EA that comes together with a 60 days money back guarantee.

Mind you, some of these Forex robots are vigorously promoted by gurus who tells you why you should be buying it. I do not want to go into the details but if you are on the mailing list of some gurus, you should know what I mean.

Create Your Own Indicator and EAs Without Programming Here

Factors To Consider Before Buying Forex Advisors To Trade

Here are some things to consider and you decide for yourself if you should buy Forex expert advisors to trade for you.

1. Some robot may not suit all market condition.

2. Some perform well during certain period only.

3. Backtest results is no guarantee that you will get the same results when you do forward test. In backtest, the data is stable with no slippage so all trades execute nicely.

4. Backtest and forward test using demo and live account will be different.

5. Backtest and forward test using demo and live account of different brokers will also yield different results.

6. Some brokers do not have all the data so backtest results will vary. You can try running a back test with a Forex expert advisor using the same settings in the same account and get different results at the end of a test because of missing data.

7. The settings for an EA that works with one broker doesn’t mean the same EA with the same settings will work with a different broker.

8. 60 days money back guarantee doesn’t mean that you will have enough time to fully test out the Forex expert advisor in forward test and before you know it, the money back guarantee is no longer valid and you end up with another EA that would likely sit in your computer and gather digital dust.

9. Last but not least, robots are robots and you have to be the intelligence that control them. No matter how much live test or some refer to forward test you have done with a trading robot on a live or demo account, it is still history once the day or trade is over.

I have pointed out some of the drawbacks when you buy a Forex expert advisor to trade Forex for you. To buy or not to buy is your decision. What I have done is to point out some of the things that you have to look out for,

So what are the options should you decide not to buy the Forex expert advisor that you have been eyeing but still keen on using Forex robots to trade for you?


There are a few options available:

  • You can hire someone that you know to code it for you.
  • Post your job online at sites such as Elance or Odesk.
  • Search for free expert advisors online. There are many to be found, however they will require testing and understanding its trading strategy it has been programmed to do which can be very time consuming. The bonus, there could be one or some out there that may just be the one that you are looking for.


The risk of the first 2 options above as I see it are:

  • The risk of the programmer running away with your source code, tweaking it a little, and then reselling it as their own.
  • Receiving an expert advisor that doesn’t quite match the strategy you have in mind.
  • Giving away your strategy “freely” when you very much wanted to keep it to yourself.


Last but not least.

Not the easiest solution but easily the most rewarding as long as you are willing to put some time into it. Learn to code the Forex EA yourself. This way, your strategy stays with you and everything is  yours to keep, share it, charge others to do their Forex robot programming or even sell your own Forex robot.

Go to MQL4.com or MQL5.com to start learning.

You can also create your own EA without any programming knowledge. There are software available where creation of indicators and EAs are made easy using drag and drop and the code generated for you. All you have to do is to cut and paste that code into your MQL4 editor (comes with MT4) and compile it and you have your very own!

Create Your Own Indicator and EAs Without Programming Here


So Should You Buy Forex Advisors To Trade?

The decision is yours to make. You can take the shorter path and opt to buy Forex advisors to trade or have someone code it for you.

Or choose the path less taken but more rewarding to learn and code your own Forex advisor because you will learn a skill and it will stay, never to be taken away from you.

Or try out this EA builder program where you can build your own indicator and EAs with MQL4 generated for you too by clicking on the link below here.
EA Builder



Share Button
Disclaimer || Privacy Policy
If I create a link to a product in a review, sometimes I may get paid a commission if a visitor to my site purchases the product.