Debugger: how to debug mql5 code during specific period of time

 

Hi,

A newbie question: I would like to run debugger (in Mgl5 MetaEditor) over some period of time in the past. Is there a way to set up the debugger for it? I could only find in the debugger settings currency pair and time period.

Tracing the execution of my advisor in Strategy Tester with Print() or Alert() is a bit troublesome & I need watch functionality. When i debug my advisor OnTick() function is always called with time of last 24 hours.

There must be simple work around or solution for my problem but i am not aware of it... Thanks in advance for your answers!

 
Unfortunately, there is no way for the moment, Debugger only works with live chart.
 
angevoyageur:
Unfortunately, there is no way for the moment, Debugger only works with live chart.

Thank you for your prompt answer!

Does it mean that the debugger only works for the future ticks? My EA works with D1 charts so i guess that using debugger is pretty useless for it (as it is now)?

Do you have any plans to integrate the debugger into Strategy Tester?

 
KonradNo:

Thank you for your prompt answer!

Does it mean that the debugger only works for the future ticks? My EA works with D1 charts so i guess that using debugger is pretty useless for it (as it is now)?

Do you have any plans to integrate the debugger into Strategy Tester?

It works on a live chart, and can be with each new tick. Why useless on D1 chart ? D1 chart receive the same ticks as any other chart.

Forum

debugger

stringo, 2013.05.08 07:04

Servicedesk answers: "Maybe later". It is not so easy to implement this functionality right now

 

As I said I am a complete newbie:

My EA is supposed to open the positions rarely: sometimes once per a week or a month, also there are dependencies to already opened positions in other currencies (it is multicurrency EA). Does it mean that I have leave it for debugging for days/weeks to watch EA internals when the position is finally opened?

Pls correct me if i got it wrong and talking nonsense...

 
KonradNo:

As I said I am a complete newbie:

My EA is supposed to open the positions rarely: sometimes once per a week or a month, also there are dependencies to already opened positions in other currencies (it is multicurrency EA). Does it mean that I have leave it for debugging for days/weeks to watch EA internals when the position is finally opened?

Pls correct me if i got it wrong and talking nonsense...

You are right, if you want to use the debugger. But there are other ways to check/debug your code. Do you search a solution for a specific issue ?

Maybe you can use the Strategy Tester ?

 
angevoyageur:

You are right, if you want to use the debugger. But there are other ways to check/debug your code. Do you search a solution for a specific issue ?

Maybe you can use the Strategy Tester ?

Thank you for the link. Lots of interesting info to study

But I have noticed something odd: when I run Strategy Tester my EA OnInit() function is not called at all! OnTick() is getting called. (just tested it with Print())

EDIT: when I run debugger on my code it enters both OnInit() & OnTick().

What am I doing wrong???

 
KonradNo:

Thank you for the link. Lots of interesting info to study

But I have noticed something odd: when I run Strategy Tester my EA OnInit() function is not called at all! OnTick() is getting called. (just tested it with Print())

EDIT: when I run debugger on my code it enters both OnInit() & OnTick().

What am I doing wrong???

Of course OnInit() is called when you are using the Strategy Tester, but you probably don't see your print statement in the Journal tab. You have to use the viewer or open the log file. Right-click inside the Journal tab window, and you will see these options.
 

OK i have it figured out now and it seems to work fine for me. Thank you!

I just learned 2 things:

I was not aware that some Print() messages might not appear in Journal window (even though they all can be found in log file). Maybe it should be mentioned somewhere in tutorial?

When using FileWrite() debugger and Strategy Tester save files in different folders and also log files are saved in 2 different locations, which makes 4 different locations altogether. I found it confusing as sometimes I was looking into wrong log file..

Documentation on MQL5: File Functions / FileWrite
Documentation on MQL5: File Functions / FileWrite
  • www.mql5.com
File Functions / FileWrite - Documentation on MQL5
 

It is a problem that does not debug backtest. It is necessary to be able to debug problems that have occurred on a certain date. If the debugger only debugs with ticks of real time, it does not help us. We need to debug the errors that we have detected in the backtest, past time ... and in this way to solve the problems that may arise in real time. It does not make any sense that the debugger can not debug ticks in the past time in a backtest.

WE NEED TO DEBUGG THE TIME OF THE STRATEGY TESTER, NOT THE REAL TIME.

WE NEED TO DEBUGG THE PROBLEMS THAT OCCUR IN BACKTEST. WE ARE NOT GOING TO WAIT BEHIND THE SCREEN DAYS OR MONTHS TO WHICH THE PROBLEM ARISES IN REAL TIME. DEBUGG REAL TIME DOES NOT HELP US ANYTHING, METATRADER DEVELOPERS HAVE TO UNDERSTAND THIS.

 
George.00:

We need to debug the errors that we have detected in the backtest, past time

WE NEED TO DEBUGG THE TIME OF THE STRATEGY TESTER, NOT THE REAL TIME.

  1. You know when. Add an if statement and print out your variables, including _LastError and find out why.
  2. Don't SHOUT AT US, that is very RUDE of you.
Reason: