FX STRATEGY DEVELOPMENT
Te MetaEditor includes a basic intellisense, but
it lacks the fine
details that make it so convenient in Visual Studio.
I am used to programming in C# where I can type the first few letters of a variable or class, then the IDE fills out the rest. When I type “Mes” in C# and push the space bar, I know that the MessageBox option will show up (assuming that required
I declared the namespace).
Te MetaEditor includes a list of options for reserved words. Te programmer must then either pick the option with the mouse or push enter.
I know it seems trivial to require pushing enter in lieu of the space bar, but think about how many times code reuses the same reserved words or variables. Te extra presses of keys really do add up to a lot of unnecessary typing motions. Tat’s doubly true for a thirty year old that already wears a wrist brace for carpal tunnel pain
Te MetaEditor’s biggest weakness is that it does not see variable names. We oſten write EAs that incorporate several thousand lines of code. Tracking the names of tens of variables poses its own challenges. When the coder types in the same set of variable names repeatedly, it would be nice
84 FX TRADER MAGAZINE April - June 2012
to simply type the first three letters and move on. Copy and paste might provide a decent alternative. Te problem is that variables usually group together. You cannot keep 5 different copy and paste items readily available.
Te MetaEditor allows functions to return invalid types. Functions declared as double can return strings, integers or nothing at all. Te MQL4 compiler does not track whether or
error message. I cannot count how many hours that I’ve wasted tracking down variables that look accurate, only to realize that I declared the wrong data type. Tis usually happens when I’m on autopilot, pounding out code. What seems efficient at the time commonly costs several hours of hair pulling frustration.
MQL TROUBLESHOOTING TECHNIQUES
The MQL programmers on staff here usually resort to any of the following techniques. You may find that testing them in groups helps with improving the bug fixing process even more.
Debug error
compiler
This one can be the most frustrating. The MetaEditor attempts
not these are valid. It leaves it up to the coder to discover the invalid type during real time testing. Tis oversight is a nightmare for the unwitting programmer that mistakenly returns the wrong type.
Tis is even more true when a double function is erroneously returned to an integer variable. MQL4 does not prevent illegal double to int casts. Even worse, the expert advisor continues running with a 0 value for the interger instead of throwing an exception or
to hint at which line of code causes the compiling error. I say attempts because it gets it wrong more often than it gets it right. Tere’s nothing more irritating than looking at a perfectly legitimate line of code that the compiler flags as problematic.
I almost always resort to commenting out more and more large blocks of the expert advisor until the issue disappears. I begin with commenting out a single line of code. If that doesn’t work, then
Page 1 |
Page 2 |
Page 3 |
Page 4 |
Page 5 |
Page 6 |
Page 7 |
Page 8 |
Page 9 |
Page 10 |
Page 11 |
Page 12 |
Page 13 |
Page 14 |
Page 15 |
Page 16 |
Page 17 |
Page 18 |
Page 19 |
Page 20 |
Page 21 |
Page 22 |
Page 23 |
Page 24 |
Page 25 |
Page 26 |
Page 27 |
Page 28 |
Page 29 |
Page 30 |
Page 31 |
Page 32 |
Page 33 |
Page 34 |
Page 35 |
Page 36 |
Page 37 |
Page 38 |
Page 39 |
Page 40 |
Page 41 |
Page 42 |
Page 43 |
Page 44 |
Page 45 |
Page 46 |
Page 47 |
Page 48 |
Page 49 |
Page 50 |
Page 51 |
Page 52 |
Page 53 |
Page 54 |
Page 55 |
Page 56 |
Page 57 |
Page 58 |
Page 59 |
Page 60 |
Page 61 |
Page 62 |
Page 63 |
Page 64 |
Page 65 |
Page 66 |
Page 67 |
Page 68 |
Page 69 |
Page 70 |
Page 71 |
Page 72 |
Page 73 |
Page 74 |
Page 75 |
Page 76 |
Page 77 |
Page 78 |
Page 79 |
Page 80 |
Page 81 |
Page 82 |
Page 83 |
Page 84 |
Page 85 |
Page 86 |
Page 87 |
Page 88 |
Page 89 |
Page 90 |
Page 91 |
Page 92 |
Page 93 |
Page 94 |
Page 95 |
Page 96 |
Page 97 |
Page 98 |
Page 99 |
Page 100 |
Page 101 |
Page 102