Forex
Google

Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


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 01-08-2006, 05:25 PM
anca anca is offline
Junior Member
 
Join Date: Nov 2005
Posts: 1
anca is on a distinguished road
Red face Debugging EA?

When you are working with an EA, is it possible to put the values of a created variable in a graph/log or do you need to create the same variable in an indicator in order to see the values?

Any tips on how to develop/debug EA are appreciated.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-08-2006, 05:28 PM
Kalenzo's Avatar
Kalenzo Kalenzo is offline
Senior Member
 
Join Date: Dec 2005
Location: Bydgoszcz - Poland
Posts: 692
Kalenzo is on a distinguished road
Print(variable) -> this will be shown in terminal
Comment(variable) -> this will be shown on graph under OHLC comments
GlobalVariableSet(variable) -> this will be shown when U press F3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-08-2006, 07:08 PM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
Write vairables to a file

Hi
I debug by writing the variables to a file. Then I open the file in excel and try to figure out if all went according to plan. It is a pretty long winded way of doing things - but it does work.

If anyone knows how to delete a file in the 'int init()' please let me know, as I always have to delete the file before running a new test. Thanks.
Code:

...

if(TP > 0)
            realTP = Ask + TP * Point;
         ticket = OrderSend(Symbol(),OP_BUY,lots,Ask,slippage,realSL,realTP,nameEA+" - Magic: "+magicEA+" ",magicEA,0,Red);  // Buy
         if(ticket < 0) {
            Print("OrderSend (" + nameEA + ") failed with error #" + GetLastError() + " --> " + ErrorDescription(GetLastError()));
            writetofile("8","Error buyagain?",ErrorDescription(GetLastError()));
         } else {
            firstbuysl = realSL;
            writetofile("12za","first buy", OrderTicket());
}


void writetofile(string breakpoint1, string description1, string description2) {

int handle;
handle=FileOpen("bedug1.dat", FILE_CSV|FILE_WRITE|FILE_READ, ";");
if(handle>0){
// write data
FileSeek(handle,0,SEEK_END);
FileWrite(handle,  breakpoint1, description1,description2, CurTime(), Year(), Month(), Day(),Hour(),Minute(),Seconds(), Bid, Ask,tstop, long_ma, numberofbuys, numberofsells, firstbuycheck, firstsellcheck,firstbuyprice, firstsellprice,firstbuysl, firstsellsl,  isBuying, isSelling, isClosing, lasttradeprice, x,y,sell_trade_again, buy_trade_again,shortEma, longEma, isCrossed);
FileClose(handle);}

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-09-2006, 02:37 PM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
File writes from stratergy tester

Please note files writen while doing 'stratergy test' are writen to .../tester/Files

and I found a way to write the results out to a different file each time. In 'start int' one has to make a file name based on the current time - then use this file name as a file to write to. I will hopefully post this solution up here tonight.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

vB 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 Q0paz Metatrader 4 3 11-09-2006 11:52 AM


All times are GMT. The time now is 09:07 PM.