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);}
}