If you’re new to this series and want to check it out from the beginning, you can find that here.
In Part 21, we wrapped up the “pseudo-coding” of our EA with the OpenTrade() function. Now it’s time to “type” the EA into the MetaEditor and compile it. As I’ve mentioned before, I actually compile the EA periodically while I’m writing it and test portions of it. That just reduces the debugging necessary when we’re done. It’s like doing your quality assurance as you work.
You might do well to review Part 2 of this series to get back up to speed on MT4 and the MetaEditor.
Beginning your new EA in MetaEditor
Once you have opened your MetaEditor, click the New button on the left side of the toolbar. This will open the Expert Advisor Wizard dialog box where you can do a little preliminary description of your EA.
The options on the EA Wizard’s first dialog box allow you to tell MetaEditor what type of programming you will be doing. You will shortly see the results of choosing Expert Advisor. We have described the difference between this, Custom Indicator, and Script.
In this dialog, you have the opportunity to enter a name for your EA, Author and link information and list the Parameters you will be using. The parameters will become the “inputs” for your EA. You may remember that you can enter the input variables for your EA when you install the EA on your chart. The only important thing on this dialog box is to get the name you want to use, the rest can be changed fairly easily. If you decide on a different name, that can be changed as well, it’s just much easier to get it right here.
To add a new parameter (in the program, these parameters will be called External Variables because they can be controlled externally to the program) to the list, click the Add button and enter the name of the parameter, the type of parameter (parameter, or variable, type will be discussed in our next article) and the initial value of the parameter. Do this for each parameter in your EA. It’s not necessary to enter them all (or any of them for that matter) at this time, you will be able to add and change them within the program code. You may remember we discussed the external variables here and here. We didn’t actually discuss the initial value of the external variables, so let’s decide that now:
LotSize | double | 0.01 MA1 | int | 3 MA2 | int | 30 SLPoints | int | 150 TPPoints | int | 250 MagicNumber | int |1234567
I thought a 3 SMA crossing over a 30 SMA would be a good default. Also, since most brokers are 5-digit, I selected 150 points and 250 points (15 pips and 25 pips) as our defaults for SL & TP respectively. Also, most brokers will treat a LotSize of 0.01 as a nominal 1,000 unit trade. Again, a good default. And, or course, the Magic Number can be anything we want it to be. It’s just an identifying number. Remember, these are numbers you can change when you run the EA to test the effectiveness of other values.
Now, just hit the finish button and you’ll have your EA “framework” in place. We’ll continue from this point tomorrow. Thanks for your attention and have a great evening. Oh, and follow me on Twitter.
Latest posts by admin (see all)
- Currency Pairs in Forex- 8 methods on how to find them - October 22, 2017
- Online Forex Trading: The Benefits and Dangers - October 22, 2017
- How to Use Currency Strength for Trading Success - October 21, 2017
Winner’s Edge Trading, as seen on: