Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


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

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-27-2006, 07:42 PM
Junior Member
 
Join Date: Sep 2006
Posts: 9
Q0paz is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-28-2006, 06:55 PM
Member
 
Join Date: Nov 2005
Posts: 49
4xCoder is on a distinguished road
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);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-31-2006, 06:58 AM
cubesteak's Avatar
Senior Member
 
Join Date: Jul 2006
Location: Southern California
Posts: 163
cubesteak is on a distinguished road
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:
Originally Posted by Q0paz
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
__________________

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-09-2006, 11:52 AM
Junior Member
 
Join Date: Sep 2006
Posts: 9
Q0paz is on a distinguished road
Thanks very much for the comments.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

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


All times are GMT. The time now is 01:50 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.