How to Create a Forex EA - The #1 Blog on trading, personal investing! Best Tips for Beginners

Header Ads

How to Create a Forex EA

Greetings, earthlings! I’m back with another article on the basics of creating a forex expert advisor. But before we dive right into the wonderful world of coding, let’s start with a little assistance from the Gandalf of forex robots… the MetaEditor Wizard!
I wish I could say that this particular wizard comes in gleaming white robes and has a magic-wielding staff, but it simply looks like this:
forex ea generate
Now this little pop-up window may not look like much, but I assure you that it’s as powerful as a wizard gets. With this tool, you can create simple forex expert advisors that can automatically analyze technical indicators or execute trades without having to write a single line of code yourself.
All you need to do to summon the wizard is face northeast, clap your hands three times, and chant… Oh wait, that one’s for triggering a market crash. We don’t want that. To access the MQL Wizard, just open MetaEditor on your trading platform then click “New” on the upper left side:
mql4 wizard metaeditor

Select “Expert Advisor (generate)”, which is the second option in the pop-up window then click Next. On this screen, you can set the general properties of the EA, such as the name, author, and link to the source.
forex ea parameters
The system parameters, which basically are your labels for the currency pair and time frame, are already set by default. Don’t worry about these inputs just yet! These default settings indicate that the EA can be applied to the current currency pair and time frame. We’ll delve into the details later on.
Next, you will have to set the signal properties of your expert advisor. You can choose from the set of technical indicators already included in the MetaTrader platform, such as good ole moving averages or MACD, and even have a combination of up to 64 indicators!
metaeditor forex ea
To add an indicator, just click Add then input the necessary fields in the pop-up window. In this example, I’ll just make use of the 100 SMA and leave the rest of the default parameters as is. Just double click on each field to edit its name, value or type.
mql wizard forex
The next step should allow you to determine the trailing stop for your forex EA. You can decide to base it on a fixed number of pips, use a technical indicator, or not have one at all. In this example, I won’t be adding a trailing stop just yet.
money management mql ea
Lastly, you can set the risk management rules by deciding to trade with a fixed volume, margin, or risk percentage. Under the fields for parameters, you can specify the percentage risk or the lot size per trade. In this example, I’d like to trade with a fixed risk of 1% of my account on each trade, as most of my trading buddies do.
mql4 risk management forex ea
Before you hit the Finish button, take a deep breath and make sure you’re ready to have lines of code thrown at your face. Ready? Okay, I’ll hold your hand. 3… 2… 1…
forex ea code
And there you have it! Just hit Compile or F7 to make sure that your code is error-free. Now go and impress your date by humble-bragging that you’ve learned to write hundreds of lines of code overnight, no biggie.
Next week, we’ll take a closer look into the structure of a forex expert advisor and how functions are executed. Stay tuned!