Bamboozled by this loop! - page 2

 

If you want to find your errors quicker you need to be able to see what is going on . . . MT4 doesn't have a proper debugger that you can step through line by line so you have to get creative and add info so you can track it's progress through your code . . how ? well I use Print() statements throughout my code and a Debug level . . .

I have an extern . . .

extern int Debug_Level=0 ;  //  set to a value from 0 to 5, 0 = no debugging (default), 5 = max debugging messages

. . . a bool . . .

bool  D1, D2, D3, D4, D5;

Within init() I have this . . .

   D1=false; D2=false;D3=false;D4=false;D5=false;

   switch(Debug_Level) {
      case 5: D5=true;
      case 4: D4=true;
      case 3: D3=true;
      case 2: D2=true;
      case 1: D1=true;
      }

. . . then I can do things like this . . .

if (D1) Print("Going long"," Bid= ",Bid);

and this . . .

if (D5) Print("Watchdog: Ticket = ",OrderTicket(), "Type = ",OrderType());

Using the value in the extern I can govern the level of debugging messages . . from no debugging messages in the Experts/Journal tab to flooding it with messages . . .

 
ernest02:


OK! I have found the reason why the Sell Stop Orders are deleted!@


Ah OK . . . not enough margin, you should test this before you place an order . . .
 
RaptorUK:
Ah OK . . . not enough margin, you should test this before you place an order . . .

Thanks a lot for all your help RaptorUK! Much appreciated! I will implement your debugging scheme in future.

Know about checking for availability of funds, but was just lazy I guess to write the code! Will fix that!

 
ernest02:

Thanks a lot for all your help RaptorUK! Much appreciated! I will implement your debugging scheme in future.

Know about checking for availability of funds, but was just lazy I guess to write the code! Will fix that!


You are most welcome . . . I know about being lazy too :-) I've spent the last 2 months creating some generic functions to replace my "lazy" code . . it had to be done, I'm considering it an investment in my future. Good news is that I'm almost done and will soon be coding the "method" part of my EA.
 
RaptorUK:
You are most welcome . . . I know about being lazy too :-) I've spent the last 2 months creating some generic functions to replace my "lazy" code . . it had to be done, I'm considering it an investment in my future. Good news is that I'm almost done and will soon be coding the "method" part of my EA.
You know what? I think you can make a lot of money by selling your generic functions. I for one will be willing to pay for it. Consider the possibility at least.