| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Debugging
Anyone got any input on how to debug scripts ?
I have been starting to try to convert some Easy Language code to MQL4 and am still trying to understand how the plotting of indicator values works. This snippet below is from an indicator I found on this board, but when I apply it my system locks up. From someone used to coding in Visual Studio, how do you overcome the inability to step through your code to check values etc. In another indicator I wrote I was able to compile it but when I applied it all I got was divide by zero errors. When I added lots of if(var > 0) type stuff it also locked up. So question 2 would be how do you recover your setup if an indicator has been applied that locks the system up. i.e. is there some config file somewhere that tells the system what indicators to apply at startup that can be hacked to remove duff indicators. Thanks. Paz //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- i=Bars-counted_bars-1; while(i>=0) { double high =High[i]; double low =Low[i]; double open =Open[i]; double close=Close[i]; ExtMapBuffer1[i]=(close-low)-(high-close); level = close; } //---- return(0); } edited cos I carn't spell |
|
|||
|
You're stuck in a the while loop because you never change the value of i. See the line in red below.
//+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- i=Bars-counted_bars-1; while(i>=0) { double high =High[i]; double low =Low[i]; double open =Open[i]; double close=Close[i]; ExtMapBuffer1[i]=(close-low)-(high-close); level = close; i--; } //---- return(0); } |
|
||||
|
Unfortunately, the only thing we have at our disposal is the good ol' Print() function. I normally put an
extern bool Debugging = true; and then before each print statement do: if (Debugging) Print ("MyVar="+MyVar); because every time I take them out, I always need the buggers again. The print statements come out on the Experts tab of the "Terminal" window. Anyway, I use them all the time to debug crap. Its a big PITA, but it works. The MetaEditor is a big tease. It even lets you set break points, but there is no debugging. Oh well, at least they don't make us write with EMACS or vi. ![]() Cheers, CS BTW - you CAN write custom DLL's in VC++. Check out the doc for how.... Quote:
__________________
Join the MultiBroker M1 and TICK Data Bank Project Imagine 90-99% modeling quality in MT4 back testing with free data from your broker! Come see our current list of covered brokers. |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Debugging EA with printouts? | resalin | Setup Questions | 3 | 05-05-2007 12:37 PM |
| Debugging EA? | anca | Expert Advisors - Metatrader 4 | 3 | 01-09-2006 02:37 PM |