If you were logged in you would gain 3 XP for posting a reply.
You are replying to:
Debugging in MQL MQL is a very basic scripting language. Fixing bugs in MQL Cheap T.J. Tynan Jersey , unfortunately, is not simple at all. The MetaEditor compiler that MetaQuotes provides simply does not incorporate the highly developed tools that most programmers are accustomed to using.
MQL4 bug fixing problems
Visual Studio and other sophisticated IDEs (integrated development environments) contain many features that make it easy to fix code while the coder writes it. The greatest illustration of this are break points. A break point is a point in the program where the compiler informs the computer to stop executing the code when it arrives at that specific line.
Consider the example where a trailing stop sets a new stop inaccurately. The common instinct for most programmers would be to run the expert advisor on the visual backtester, then insert break points on the lines of code shortly after the trailing stop calculations. Break points stop the code, allowing the coder to peer inside the heart of the EA to see what it saw at the time it made a decision. The key advantage in Visual Studio is that the values of all of the variables are clearly visible. It is possible to walk through the program step by step. Whenever one of the steps does not follow the desired rules Cheap Teemu Pulkkinen Jersey , the required modification is usually obvious. MetaQuotes thankfully included break points in MQL5. They are not available in MQL4.
The absence of full intellisense support inhibits my programming speed more than anything. Intellisense observes the use of reserved words like OrderSelect() or ObjectGet(). The MetaEditor includes a rudimentary 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 press the space bar, I know that the MessageBox option will appear (assuming that I declared the appropriate namespace). The MetaEditor includes a list of candidates for reserved words. The programmer must then either choose the option with the mouse or press enter.
I know it seems trivial to require pushing enter in lieu of the space bar Cheap David Perron Jersey , but think about how many times code resuses the same reserved words or variables. The extra presses of keys really do add up to a lot of unnecessary typing actions. That's doubly true for a thirty year old that already wears a wrist brace for carpal tunnel pain.
The MetaEditor's biggest weakness is that it does not discover variable names. We often write expert advisors that comprise 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 to simply type the first three letters and move on. Copy and paste might provide a decent alternative. The problem is that variables usually group together. You cannot keep 5 different copy and paste items readily available.
The MetaEditor allows functions to return invalid types. Functions declared as double can return strings, integers or nothing at all. The MQL4 compiler does not track whether or not these are valid. It leaves it up to the programmer to discover the invalid type during real time testing. This oversight is a nightmare for the unwitting programmer that mistakenly returns the wrong type.
This is even more true when a double function is erroneously returned to an integer variable. MQL4 does not forbid 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 error message. I cannot count how many hours that I've lost tracking down variables that look dead-on Cheap Erik Haula Jersey , only to realize that I declared the wrong data type. This usually happens when I'm on autopilot, pounding out code. What appears efficient at the time frequently costs several hours of hair pulling irritation.
MQL bug fixing techniques
The MQL programmers on staff here usually resort to any of the following techniques. You may find that testing them in groups assists with improving the debugging process even more.
Debug compiler error
This one can be the most frustrating. The MetaEditor attempts 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. There'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 code until the issue leaves. I start with commenting out a single line of code. If that doesn't work, then I comment out ten lines. If that doesn't work, I may comment out entire functions or blocks of code. When the compiler finally runs properly Cheap Keegan Kolesar Jersey , you know that the last section of commented out code comprises the bug.
Next, you work backwards. Commence with making the offending commented-out section smaller and smaller until the error reappears. Now, you have finally zeroed in on the actual source of the problem.
Debug in real time or on the backtester
My favorite technique of debugging is to comment most of the relevant decision information onto the screen, which is done using the Comment() function. I then run the visual backtester Cheap Luca Sbisa Jersey , watching how the data behaves in relation to the visual information.
On screen comments are essentially jury-rigged break points. Controlling how and when they appear allows the programmer to step through the code to uncover the issue. The only difference is that comments do not forcefully prevent the code from running. The text which appears is very small. Aside from that, I really like that fact that it's so robust. The comment function always works without a hitch, making it the best friend of a coder that's troubleshooting code.
Debugging in MQL MQL is a very basic scripting language. Fixing bugs in MQL Cheap T.J. Tynan Jersey , unfortunately, is not simple at all. The MetaEditor compiler that MetaQuotes provides simply does not incorporate the highly developed tools that most programmers are accustomed to using.
MQL4 bug fixing problems
Visual Studio and other sophisticated IDEs (integrated development environments) contain many features that make it easy to fix code while the coder writes it. The greatest illustration of this are break points. A break point is a point in the program where the compiler informs the computer to stop executing the code when it arrives at that specific line.
Consider the example where a trailing stop sets a new stop inaccurately. The common instinct for most programmers would be to run the expert advisor on the visual backtester, then insert break points on the lines of code shortly after the trailing stop calculations. Break points stop the code, allowing the coder to peer inside the heart of the EA to see what it saw at the time it made a decision. The key advantage in Visual Studio is that the values of all of the variables are clearly visible. It is possible to walk through the program step by step. Whenever one of the steps does not follow the desired rules Cheap Teemu Pulkkinen Jersey , the required modification is usually obvious. MetaQuotes thankfully included break points in MQL5. They are not available in MQL4.
The absence of full intellisense support inhibits my programming speed more than anything. Intellisense observes the use of reserved words like OrderSelect() or ObjectGet(). The MetaEditor includes a rudimentary 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 press the space bar, I know that the MessageBox option will appear (assuming that I declared the appropriate namespace). The MetaEditor includes a list of candidates for reserved words. The programmer must then either choose the option with the mouse or press enter.
I know it seems trivial to require pushing enter in lieu of the space bar Cheap David Perron Jersey , but think about how many times code resuses the same reserved words or variables. The extra presses of keys really do add up to a lot of unnecessary typing actions. That's doubly true for a thirty year old that already wears a wrist brace for carpal tunnel pain.
The MetaEditor's biggest weakness is that it does not discover variable names. We often write expert advisors that comprise 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 to simply type the first three letters and move on. Copy and paste might provide a decent alternative. The problem is that variables usually group together. You cannot keep 5 different copy and paste items readily available.
The MetaEditor allows functions to return invalid types. Functions declared as double can return strings, integers or nothing at all. The MQL4 compiler does not track whether or not these are valid. It leaves it up to the programmer to discover the invalid type during real time testing. This oversight is a nightmare for the unwitting programmer that mistakenly returns the wrong type.
This is even more true when a double function is erroneously returned to an integer variable. MQL4 does not forbid 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 error message. I cannot count how many hours that I've lost tracking down variables that look dead-on Cheap Erik Haula Jersey , only to realize that I declared the wrong data type. This usually happens when I'm on autopilot, pounding out code. What appears efficient at the time frequently costs several hours of hair pulling irritation.
MQL bug fixing techniques
The MQL programmers on staff here usually resort to any of the following techniques. You may find that testing them in groups assists with improving the debugging process even more.
Debug compiler error
This one can be the most frustrating. The MetaEditor attempts 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. There'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 code until the issue leaves. I start with commenting out a single line of code. If that doesn't work, then I comment out ten lines. If that doesn't work, I may comment out entire functions or blocks of code. When the compiler finally runs properly Cheap Keegan Kolesar Jersey , you know that the last section of commented out code comprises the bug.
Next, you work backwards. Commence with making the offending commented-out section smaller and smaller until the error reappears. Now, you have finally zeroed in on the actual source of the problem.
Debug in real time or on the backtester
My favorite technique of debugging is to comment most of the relevant decision information onto the screen, which is done using the Comment() function. I then run the visual backtester Cheap Luca Sbisa Jersey , watching how the data behaves in relation to the visual information.
On screen comments are essentially jury-rigged break points. Controlling how and when they appear allows the programmer to step through the code to uncover the issue. The only difference is that comments do not forcefully prevent the code from running. The text which appears is very small. Aside from that, I really like that fact that it's so robust. The comment function always works without a hitch, making it the best friend of a coder that's troubleshooting code.
Takin. Cheap MLB Jerseys Wholesale Jerseys China Wholesale Jerseys China Wholesale Hockey Jerseys Cheap Jerseys Wholesale Wholesale Jerseys Wholesale Jerseys Wholesale Jerseys Cheap NFL Jerseys Cheap NFL Jerseys China