Data problems caused by Print??

 

Trying to debug an EA by adding Print statements:

I have 11 Print statements that should print every bar (in this case daily bars). The problems are:

1. For day one only 7 items print,

2. For days 2-5 nothing is printed,

3. Only 6 items print for day 6.

everything is ok after that.

I found out that when I remove (i.e. comment out) my last print statement [ Print("Flag: ",Flag); ] then everything works as you'd expect...I'm running from 1 Jan 2012 to 4 Feb 2012.

There is nothing ground breaking in this code (just calculating MACDs), but I'm going crazy trying to figure out what's going wrong.

Are there issues/limitations with the Print function that someone can clue me into?

Thanks.

#property copyright "Anthony"

extern double  Lots           = 0.1;
extern double  StopLossPips   = 6000; // 320 = 0.0032, because of prices out to 5 decimals the pips have to have one more decimal, i.e. 320 in this code is actually only 32 pips (0.0032)
extern double  TakeProfitPips = 100; // 210 = 0.0021
extern double  Threshold      = 0.004;
extern double  Flag           = 0;
extern double  TimePeriod     = 1440; // minutes: 60 = hourly, 240 = 4-hour, 1440 = daily

double MACDLineBuffer0        = 0;
double SignalLineBuffer0      = 0;
double Difference0            = 0;

double MACDLineBuffer1        = 0;
double SignalLineBuffer1      = 0;
double Difference1            = 0;

double MACDLineBuffer2        = 0;
double SignalLineBuffer2      = 0;
double Difference2            = 0;

extern int     FastMAPeriod   = 12;
extern int     SlowMAPeriod   = 26;
extern int     SignalMAPeriod = 9;

extern string  CcyPair        = "EURUSD";

static datetime lastTF        = 0; //TF = Timeframe

int start()
{
if( lastTF == iTime(CcyPair,TimePeriod,0))
   return( 0 );
   
lastTF = iTime(CcyPair,TimePeriod,0);

Print("iTime: ",iTime(CcyPair,TimePeriod,0));

MACDLineBuffer0      = iMACD(CcyPair,TimePeriod,FastMAPeriod,SlowMAPeriod,SignalMAPeriod,PRICE_CLOSE,MODE_MAIN,0);
SignalLineBuffer0    = iMACD(CcyPair,TimePeriod,FastMAPeriod,SlowMAPeriod,SignalMAPeriod,PRICE_CLOSE,MODE_SIGNAL,0);
Difference0          = MACDLineBuffer0 - SignalLineBuffer0;
      
MACDLineBuffer1      = iMACD(CcyPair,TimePeriod,FastMAPeriod,SlowMAPeriod,SignalMAPeriod,PRICE_CLOSE,MODE_MAIN,1);
SignalLineBuffer1    = iMACD(CcyPair,TimePeriod,FastMAPeriod,SlowMAPeriod,SignalMAPeriod,PRICE_CLOSE,MODE_SIGNAL,1);
Difference1          = MACDLineBuffer1 - SignalLineBuffer1;
      
MACDLineBuffer2      = iMACD(CcyPair,TimePeriod,FastMAPeriod,SlowMAPeriod,SignalMAPeriod,PRICE_CLOSE,MODE_MAIN,2);
SignalLineBuffer2    = iMACD(CcyPair,TimePeriod,FastMAPeriod,SlowMAPeriod,SignalMAPeriod,PRICE_CLOSE,MODE_SIGNAL,2);
Difference2          = MACDLineBuffer2 - SignalLineBuffer2;

Print("MACDLineBuffer0: ",MACDLineBuffer0);
Print("SignalLineBuffer0: ",SignalLineBuffer0);
Print("Difference0: ",Difference0);
      
Print("MACDLineBuffer1: ",MACDLineBuffer1);
Print("SignalLineBuffer1: ",SignalLineBuffer1);
Print("Difference1: ",Difference1);
      
Print("MACDLineBuffer2: ",MACDLineBuffer2);
Print("SignalLineBuffer2: ",SignalLineBuffer2);
Print("Difference2: ",Difference2);
      
//Print("Flag: ",Flag);

return(0);
}
 
Are there issues/limitations with the Print function that someone can clue me into? Depending on the speed of the back-tester, the Print command does-not print all instances to the Journal. However, all instances should be Printed within the Log. Tester Log is located within the tester folder. Comment() can help you see real-time values on screen, and can become a good sub depending.....
 

If you have at log prints "Flag: 0" try use (but I am not sure for this, you need to check) :

I know Comment() or Print() had some limitations on 4 digits in past for doubles. But I think it was for Comment().

Print( "Flag: " , DoubleToStr( Flag , Digits + 1 ) ); // 1 or other num.+
 

It works well at my tests with and withoud commented //Print("Flag: ",Flag); The code is ok and since I am MQL programmer I have not notice such problems related with Print function. The problem seems to be somewhere else. Make sure you have available all backhisroty that your indicators require. Start your testing from a later date and note if that makes a difference.

Also try using control points or every tick testing modes at visual mode and lower speeds. This may give us a clue.

Finaly test it on another terminal because at the moment your one can be buggy.

 
cyberfx.org:

Finaly test it on another terminal because at the moment your one can be buggy.

LOL . . . ubzen has already given the most logical explanation.
 
ubzen:
Are there issues/limitations with the Print function that someone can clue me into? Depending on the speed of the back-tester, the Print command does-not print all instances to the Journal. However, all instances should be Printed within the Log. Tester Log is located within the tester folder. Comment() can help you see real-time values on screen, and can become a good sub depending.....

Thanks to all those who replied. As ubzen wrote, there is an issue with what is printed to the Journal, however all is printed to the Log, and the results are correct.
 
apult:

Thanks to all those who replied. As ubzen wrote, there is an issue with what is printed to the Journal, however all is printed to the Log, and the results are correct.


actually, no.

i have seen the strategy tester miss large chunks of print output sent to the log file.

there are some definite issues there, which if meta trade were honestly interested in providing a reliable platform, they would fix.

 but it's our word against their's so what can you do? 

 
jon1:


actually, no.

i have seen the strategy tester miss large chunks of print output sent to the log file.

there are some definite issues there, which if meta trade were honestly interested in providing a reliable platform, they would fix.

 but it's our word against their's so what can you do? 

  

If you can re-create the issue. You can send a bug-report to meta-quotes and they'll fix.[ in most cases ]
 
ubzen:
If you can re-create the issue. You can send a bug-report to meta-quotes and they'll fix.[ in most cases ]


lets put this way: I am a windows developer, i have many tools in my arsenal. when something does not work, i fall back to something that i know does work, and check.

in my code, if i substitute calls to Print() with calls to the windows kernel OutputDebugString(), everything is printed, as expected. items that are missing from the journal and the log file appear as expected.

i don't use print any more, instead i use an external viewer ( http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx ,  http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362(v=vs.85).aspx )

 i should not need to re-create something that should have been picked up in metatrade's basic unit testing.  


if anyone else wants to use my workaround until metatrade get their act together, here it is: (the mql4: prefix is just so you can apply a filter in the viewer to mask out other messages sent by other programs). if you are debugging a dll, it can call OutputDebugString itself directly, and those messages end up in the same place.

/*
 
  void WINAPI OutputDebugString( _In_opt_  LPCTSTR lpOutputString);
  
 */
#import "Kernel32.dll"
  int     OutputDebugStringA(string szText);
#import

bool debugPrint(string msg) {
        OutputDebugStringA(StringConcatenate("mql4:",msg));
        }
 
jon1:lets put this way: I am a windows developer, i have many tools in my arsenal. when something does not work, i fall back to something that i know does work, and check.

in my code, if i substitute calls to Print() with calls to the windows kernel OutputDebugString(), everything is printed, as expected. items that are missing from the journal and the log file appear as expected.

i don't use print any more, instead i use an external viewer ( http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx ,  http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362(v=vs.85).aspx )

i should not need to re-create something that should have been picked up in metatrade's basic unit testing.  

if anyone else wants to use my workaround until metatrade get their act together, here it is: (the mql4: prefix is just so you can apply a filter in the viewer to mask out other messages sent by other programs). if you are debugging a dll, it can call OutputDebugString itself directly, and those messages end up in the same place.

Like this one here:

https://www.mql5.com/en/forum/136080 &&

https://www.mql5.com/en/forum/142099  &&

https://www.mql5.com/en/forum/143511 &&

https://www.mql5.com/en/forum/126497 

I could go on-and-on but i guess it's much easer for people to make accusations about how meta-quotes sucks. When Rosh [of Meta-Quotes] ask for reproducibility to track the so-called bugs. Your kind of response is alway given. It's cool I don't need you to do meta-quotes job for them. Just don't give us fire, we're already standing in hell. ;-)

 
ubzen:

Like this one here:

https://www.mql5.com/en/forum/136080 

 


nice