molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming
http://www.molanis.com/forum/

Saving Huge Amounts of Time when Debugging Your EA Design?
http://www.molanis.com/forum/viewtopic.php?f=6&t=1671
Page 1 of 1

Author:  cfx [ Tue Jul 24, 2012 9:58 pm ]
Post subject:  Saving Huge Amounts of Time when Debugging Your EA Design?

One of the HUGE time savers that you can employ, is the tagging of your code whenever you use an MQL block. If you have an EA design with multiple signals, this will save you time searching and scanning your written code for the trade executions that show-up in the Tester Journal.

The Tester Journal shows you the trade that's being executed, but if all of your trades start with the same exact code (like those that trade across the same span of time), then the Tester Journal becomes useless for determining which trade just got triggered, as the text that shows-up in the Tester Journal might be too long to distinguish and/or identify the trade. Thus, you end up spending a massive amount of time as you pause the Tester and begin searching your written code (line-by-line) for the conditions that triggered the trade. Extremely exhausting and highly frustrating to say the least. You can literally spend hours just doing this iterative kind of trouble-shooting and debugging.

There's an easier way to identify that trade that is very simple, quick and accurate. Simply encode a 'Trade Tag' as the very first line of code. Now, when you look at the Tester Journal, you will know precisely which trade just got triggered.

Example:

I have an EA that has eight (8) different potential trade triggers. All of them start out with the same exact piece of code:

((DayOfWeek() != 0
&&
DayOfWeek() != 5
&&
DayOfWeek() != 6
&&
TimeHour(TimeCurrent()) <= 23 && TimeMinute(TimeCurrent()) < 57)
||
(DayOfWeek() == 5
&&
TimeHour(TimeCurrent()) <= 21 && TimeMinute(TimeCurrent()) < 57))


So, there is no possible way to look at the Tester Journal and know which trade is being executed, as all trades will print to the Journal in the same exact way as seen above. I then have to stop the Tester and start pouring through the charts and the written code, looking for the market condition that just got triggered. Not anymore.


The EA contains eight (*) different sub-EAs. I simply encoded the eight (8) trade types this way:

Branch #1: Long "Name of System A"
Branch #2: Long "Name of System B"
Branch #3: Long "Name of System C"
Branch #4: Long "Name of System D"
Branch #1: Short "Name of System A"
Branch #2: Short "Name of System B"
Branch #3: Short "Name of System C"
Branch #4: Short "Name of System D"

I then added this to the top of each code block that contains the code for the respective EA:

0+1 == 1
0+2 == 2
0+3 == 3
0+4 == 4

0-1 == -1
0-2 == -2
0-3 == -3
0-4 == -4

All positive numbers belong to the Long branch and all negative numbers belong to the Short branch. Since each trade is a mirror image of the other - one for the Long side and one for the Short side - I instantly know which code block is being triggered, because the Tester Journal will always show the very first string of characters of the MQL being executed. Therefore, the very first thing that prints to the Tester Journal, is the encoded "Trade Tag."

No more searching for code, scanning charts and re-calculating (by hand!) the conditions that might have triggered a particular code block.

In this pic, the Trade Tag 0-3 == -3 lets me know that Branch #3: Short "Name of System C" was just triggered.


Image

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/