MQL5: Using custom indicator in strategy tester to debug an EA.

 

I'm finally making a serious attempt to convert my MQL4 codebase  to MQL5.

First, I'd like to mention this: what a freakin' nightmare this conversion is.

That said, after a brutal 3 day effort to convert one of my primary indicators to MQL5 - I have achieved near similar results with its MQL4 predecessor.

Here's side-by-side visuals which are nearly identical but notice the MQL5 has 'missing events' (events are tagged with a price label); this is a minor debug issue, could be data, could be something else,


Continuing on, while debugging the indicator,my buffers 'flash' (disappear, on-off-on-off, etc.) and go askew. I had to snap a screen shot at the moment the buffers were visible to show this behavior, behavior of which does not happen on a live chart. Aagain, not really an issue - I'm able to debug the indicator even though the visuals are wrecked.



The real issue is how to use this indicator on top of my EA while debugging?



Not trying to bemoan the issue - clearly, MT5's 64-bit architecture is rapidly becoming a must have. Then there are the rave reviews from the "after the switch from MT4 -> MT5 - I'm  never going back" group that keep me pushing onward.

Honestly, I don't see it (yet). I must be missing something.

My indicators are golden - class-based.  My EAs don't pull data from the indicators but rather, uses the same classes and derive data internally. I use indicators to visually represent what is going on 'under the hood'.

Hopefully, I've described the issues I've experienced. Any help and/or guidance will be much appreciated.
 
Add an iCustom call to your indicator into your EA. It will automatically be added to the Strategy Tester chart.
 
Alain Verleyen #:
Add an iCustom call to your indicator into your EA. It will automatically be added to the Strategy Tester chart.

Thanks much. That did the job - albeit - this represents a paradigm shift to the OOP approach I've used for the past several years.

Going to have to let this gel for a bit - see if I'll be able to salvage our codebase.

Below, working (sort of...)


The issue I have is that I was new to MQL4/OOP when I started using classes - which, btw, are truly amazing - and, without a lot of *great* examples, tutorials, etc. - my coding approach took a unique turn. With OOP, a multitude of calcs can be implemented, stored in structs, and instantly available.The data interchange "bus" (via arrays of double[] with buffers) just did not jive with what I thought of OOP at the time. Unless I'm mistaken, iCustom() only provides a 'Hook' that makes linear, single-field 'Buffers' of doubles available - a far cry from a well-designed, canonical structures.

A few of the less complex types I use look like this:

  //-- Pivot Record
  struct PivotRec
         {
           EventType     Event;                    //-- Pivot Event
           int           Lead;                     //-- Action of last Boundary Hit
           int           Bias;                     //-- Bias 
           double        Price;                    //-- Last Event Pivot (Fibonacci)
           double        Open;                     //-- Close price at time of Event
           double        High;                     //-- Pivot High
           double        Low;                      //-- Pivot Low
         };

  //-- Fibonacci Record
  struct FibonacciRec
         {
           EventType     Event;                    //-- Event related to State Changed tick cleared
           FibonacciType Level;                    //-- Current Fibonacci Level
           double        Price;                    //-- Fibonacci Pivot from Last Event
           double        Percent[MeasureTypes];    //-- Actual Fibonacci Percents by Measure
         };

  //-- Fractal Record
  struct FractalRec
         {
           FractalType   Type;                     //-- Type
           FractalState  State;                    //-- State
           int           Direction;                //-- Direction based on Last Breakout/Reversal (Trend)
           EventType     Event;                    //-- Last Event; disposes on next tick
           PivotRec      Pivot;                    //-- Last Fibonacci Event Pivot
           FibonacciRec  Extension;                //-- Fibo Extension Rec
           FibonacciRec  Retrace;                  //-- Fibo Retrace Rec
           double        Fractal[FractalPoints];   //-- Fractal Points (Prices)
         };

Is there any hope for direct access to public/protected class properties/methods -- if invoked from within the EA, shouldn't the EA have access to the Indicators Namespace?

Haven't moved too far along with the MQL5 conversion and I sincerely want to code this using standards and norms.

Thanks for the quick response.

 
Dennis Jorgenson #:

Thanks much. That did the job - albeit - this represents a paradigm shift to the OOP approach I've used for the past several years.

What shift ? You can use the same paradigm as MT4. You only have to use the iCustom call for your development, it's just a way to do what you are doing manually with MT4 (adding an indicator to the Visual Tester)
...

Is there any hope for direct access to public/protected class properties/methods -- if invoked from within the EA, shouldn't the EA have access to the Indicators Namespace?

No. But as I said, you don't need that, just do as you did with MT4.