Is it possible to debug an indicator started from an EA?

 

I have an EA that creates an indicator using iCustom()...

iCustom(symbol, period, "My_Indicator", ChartID());

When debugging the EA, is there a way to also debug the indicator (or just the indicator)?

I've had a look around, but cannot see how it can be done. I appreciate that they are both separate EXE's, but I was hoping to find some "attach to running process" type ability.

The reason I would like to do this is I am seeing a lot of 4101 errors (Wrong chart ID), when I close the chart associated with the indicator (not the same as the EA chart) by using CTRL + F4.

I'm not sure what stage the code is at, but I don't think OnDeinit() has deleted the chart at the point I am seeing the issues.

I could move all the code to the EA, but that *might* change the dynamics, or I could try to plaster the code with temporary Print() statements, which I'd rather not do.

Documentation on MQL5: Chart Operations / ChartID
Documentation on MQL5: Chart Operations / ChartID
  • www.mql5.com
ChartID - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Simply stop (delete) your indicator on different charts during debugging the EA.
 
Carl Schreiber #:
Simply stop (delete) your indicator on different charts during debugging the EA.

Hi Carl,

Yeah, that is what I am doing. The EA starts a new chart and adds an indicator to the new chart. When I close the new chart (the one with the indicator) using CTRL + F4, I start to see the 4101 errors that I shouldn't be seeing.

 

After a bit more playing around, I can see that the 4101 errors are actually happening before the OnDeinit() function is called for the indicator.

So, does anyone know what happens between pressing CTRL+F4 and the OnDeinit() being called?

Is there anything that I can hook into?

Can I prevent CTRL+F4?