Whoa! It’s Wednesday? What happened to Tuesday? As Nathan said, “Time is a slimy fellow. Always getting away like that.”
If you’re new to this series and want to check it out from the beginning, you can find that here.
In Part 22, we discussed how to use the MetaEditor and how to get your “framework” in place to start your coding. This time, we’ll discuss some of the details of the framework in preparation for compiling your EA. Compiling is programmer-speak for converting your human-readable program code (called source code) into machine readable executable code. MT4 will use the executable code to run your EA on the chart. If you have your file extensions enabled in Windows, you will note the source code has a file extension of .mq4 and the executable code will have the file extension of .ex4.
Let’s take a look at the framework we’ve got set up for our EA:
static datetime LastTradeTime = 0;
to the framework, so don’t be upset if yours doesn’t look like that.
Let’s do a little overview of what it is you’re viewing. The first group of lines are comment lines. Anything you place behind the double slashes (//) will be ignored by the compiler. As I’ve said, use LOTS of comments. In 6 months you won’t even remember what you were thinking when you wrote this (well, if you’re my age, it may be 6 minutes. ;))
You’ll notice the two lines starting with #property. The pound sign (octothorpe for you punctuation purists) signifies to the compiler that what follows is a preprocessor parameter for controlling the compilation. There are lots of things that you can include behind the # that are quite handy, but we’ll save that discussion for another day.
Following are the lines that designate the external variables. The extern keyword precedes variables that will appear in the inputs when you run your EA. You will be able to change them at runtime. (It may be obvious to some, but I’ll mention it for those that don’t pick this stuff up quickly: Runtime is programmer speak (PS) for the time when the program is run. Compiletime is PS for the time the program is compiled. You guys are going to sound like programmers by the time we’re done with this project.)
You’ll notice that we have initialized the variables. Initialization is PS for “setting the variable equal to a value when it is declared.” These are the values that the inputs will be set to if you click the reset button on the inputs dialog box.
In addition to the things we’ve discussed, you’ll notice the empty init(), deinit() and start() functions already in place in which to add your code.
Tomorrow, we’ll add our code and compile our EA for the first time. As I’ve mentioned, I usually compile the EA each time I complete a function to save some debugging time. I also pretest my functions as I’m coding them. In fact, I have a library of pretested functions that I’ll explain and share with you guys when we get done with this project.
Thanks for your attention and follow me on Twitter and LinkedIn.
Latest posts by admin (see all)
- AUDUSD approaching major resistance, prepare to sell - May 18, 2017
- Online Forex Trading: The Benefits and Dangers - May 16, 2017
- How To Trade The Fractal Indicator - April 3, 2017
Winner’s Edge Trading, as seen on: