Use of Comment() when backtesting

sonik
Posts: 3
Joined: Tue Jan 24, 2012 1:15 am

Re: Use of Comment() when backtesting

Post by sonik »

Sounds to me like the backtester is changing between ticks too fast or your comment is too long. Basically, the comment doesn't have time to output before the next comment is requested (start() function iterates every tick).

I have this issue in REALTIME trading, as my main system outputs well over a hundred lines of information (ideally). I've since had to cut it right down, because the comment wouldn't show because it was too long and not fast enough.
dietcoke
Trader
Posts: 162
Joined: Tue Nov 15, 2011 9:59 pm

Re: Use of Comment() when backtesting

Post by dietcoke »

slipshod wrote:
Here I've run into a bit of a problem. How can I tell that the EA is doing what I designed for it to do? When running the EA in normal time I can make it print to the screen via Comment(), and display a bunch of info that tells me exactly what its doing & why. I can compare that to indicators etc & verify that its working properly (or not).

However, when I try this with backtesting in visual mode, the comments flicker on the screen every now & then for a nanosecond, then are gone. I'm basically blind & can't tell precisely why its trading as it is, which is pretty frustrating.

Has anyone else run into this problem, and is there any way around it? Thanks in advance :)
I use this function

Code: Select all

//+------------------------------------------------------------------
/**
* send information to OutputDebugString() to be viewed and logged
* by SysInternals DebugView (free download from microsoft)
* This is ideal for debugging as an alternative to Print().
* The function will take up to 8 string (or numeric) arguments
* to be concatenated into one debug message.
*/
void log(
   string s1,   string s2="",   string s3="",   string s4="",   string s5="",
   string s6="",   string s7="",   string s8="",   string s9="",   string s10="",
   string s11="",  string s12="",  string s13="",   string s14="",   string s15="",
   string s16="",   string s17="",   string s18="",   string s19="",   string s20="",
   string s21="",   string s22="")
   {
   string Logout = StringTrimRight(StringConcatenate(
      WindowExpertName(), " ", Symbol(),
      " ", s1,			" ", s2,		" ", s3,		" ", s4,		" ", s5,		" ", s6,
      " ", s7,			" ", s8,		" ", s9,		" ", s10,	" ", s11,	" ", s12,
		" ", s13,		" ", s14,	" ", s15,	" ", s16,	" ", s17,	" ", s18,
		" ", s19,		" ", s20,	" ", s21,	" ", s22   ));
   OutputDebugStringA(Logout);
}

//+--------------------------------------------------------------------------

You have to import the following kernal32 function.

Code: Select all

#import "kernel32.dll"
   void OutputDebugStringA(string msg);
#import
The output can only be viewed in using debugview from sysinternals. The ouput is, however, iin real time unlike Print.

To use it call the log function where you want a comment or Print. I make the call conditional on a debug flag being set so it's easy to switch on and off.

eg.

Code: Select all

if debug (log("7Day sma=", sma7);
This will log the time, pair name of the EA/Indi and your log message into the viewer

This will wrk regardless of the mode you are working in.
I cannot code any more without this in place.
Image
garyfritz

Re: Use of Comment() when backtesting

Post by garyfritz »

DC, how is this any better than just doing a FileWrite() with the desired parameters? That's what I've been doing...
dietcoke
Trader
Posts: 162
Joined: Tue Nov 15, 2011 9:59 pm

Re: Use of Comment() when backtesting

Post by dietcoke »

garyfritz wrote:DC, how is this any better than just doing a FileWrite() with the desired parameters? That's what I've been doing...

Nothing at all, i imagine.

It's probably a tiny bit less intense on the system as it uses an api call,

there are no huge log files to manage. Once you quit debugview, the logging is lost unless you save it

Debug view allows you to tail the log outout, apply filters etc. However, these thing are also available in a decent text editor.

This was just the first decent debug method I'd seen for Empty4.
Image
AnotherBrian

Re: Use of Comment() when backtesting

Post by AnotherBrian »

I 2nd the vote for debugview - I used it when I was using Amibroker - it is very helpful, and real time rally mean real time scrolling.
Big Be
Trader
Posts: 52
Joined: Thu Nov 01, 2012 6:12 pm

Re: Use of Comment() when backtesting

Post by Big Be »

Comments Flickering

A Comment will stay up until a new Comment replaces it, whether from an EA or from an indicator.
New means next one executed

Big Be
"Big Be"
MrPip
Posts: 4
Joined: Sat Oct 27, 2012 8:16 am

Re: Use of Comment() when backtesting

Post by MrPip »

I have been using text labels for many years after getting a coding request from a cliet with poor eyesight. As mentioned in a prior post, you can then control font size and color.

I do not see where I can add an attachment of a code stubb or indicator I have written that can be used as an example.

Robert Hill aka MPip
Post Reply

Return to “Coders Hangout”