How to debug EA in live operation?

 

Hello, during the implementation of my EA it was quite easy to debug errors/warnings that happened during backtesting in the strategy tester. Now, during live operation some unexpected things happened - as expected ;-) - and I do not know how to properly debug the code now. Is there any better way to debug your code than using a lot of:

PrintFormat("...") // or
Print("...")

If not, did anyone implement a cooler debug function with different input params instead of using the standard print out functions as provided in the code snippet?

Thanks!

 
algotrader01: Is there any better way to debug your code than using a lot of:Print
Use the debugger.
 
William Roeder:
Use the debugger.

Hello William, I did not know that it is possible to use the debugger on live data. I just had a look and using the green instead of the blue arrow it starts debugging on live data indeed.


Two more questions that just arose:

  1. Is it correct that debugging on live data can be started only for one instrument at a time per MT5 instance? at least looks like that
  2. Is there any article on how to do the debugging on live data? I mean what happens if I set a breakpoint. I mean I haven't yet deep dived into that topic but I am just wondering how this is all working on live data. How I use the debugger while backtesting is to set different BreakPoints or DebugBreak() and then when backtester stops I look at the value of certain variables...


Thanks!

 
algotrader01:

Hello William, I did not know that it is possible to use the debugger on live data. I just had a look and using the green instead of the blue arrow it starts debugging on live data indeed.


Two more questions that just arose:

  1. Is it correct that debugging on live data can be started only for one instrument at a time per MT5 instance? at least looks like that
  2. Is there any article on how to do the debugging on live data? I mean what happens if I set a breakpoint. I mean I haven't yet deep dived into that topic but I am just wondering how this is all working on live data. How I use the debugger while backtesting is to set different BreakPoints or DebugBreak() and then when backtester stops I look at the value of certain variables...


Thanks!

1. Yes.

2. It works the same way as on historical data.

 

Hello and thank's for your answer. I played a bit more around with it and I think this live debugging feature is pretty cool and as it works accordingly to the one on historical data, for me, it is already easy to use.

However, one thing is still not clear to me. So, you start your EA (H1) and it runs for a couple of hours until it hits the first DebugBreak(). As it is live data, the price keeps moving and moving. So, let's say after another two hours the price reaches a certain point at which your EA would have actually opened a long position (checking entry option after a new candle has started). However, you are out and come back home 4 hours later. So, what happens now if you click "Resume Debugging"? after 2 hours (2 new candles) it reaches the point where to open a new long position. Is it trying to open it even though the price is alreay 4 hours ahead? I currently cannot imagine how such situations are handled? Thank you!

 
algotrader01:

Hello and thank's for your answer. I played a bit more around with it and I think this live debugging feature is pretty cool and as it works accordingly to the one on historical data, for me, it is already easy to use.

However, one thing is still not clear to me. So, you start your EA (H1) and it runs for a couple of hours until it hits the first DebugBreak(). As it is live data, the price keeps moving and moving. So, let's say after another two hours the price reaches a certain point at which your EA would have actually opened a long position (checking entry option after a new candle has started). However, you are out and come back home 4 hours later. So, what happens now if you click "Resume Debugging"? after 2 hours (2 new candles) it reaches the point where to open a new long position. Is it trying to open it even though the price is alreay 4 hours ahead? I currently cannot imagine how such situations are handled? Thank you!

Don't go when you started a debug session, it makes no sense.

You are asking too much theoretical questions, try it and you will see the answers yourself.

 

Well, yeah but this also applies to a more realistic case when you trade M1 or M5 candles. As soon as the debugger runs into a breakpoint you probably need a couple of minutes to see what is going on. If a minute later a trade would open you have the same scenario.

I mean this is the fundamental difference between debugging on historical and on live data so I do not know why this question sounds too theoretical for you?

Best!

Reason: