Is it possible to call custom indicators through OOP without iCustom and CopyBuffer?

 
  • 0% (0)
  • 20% (1)
  • 20% (1)
  • 60% (3)
Total voters: 5
 

There is nothing stopping you from calculating indicator values yourself. You create dynamic arrays and calculate indicator values for each bar, plus manage the sizes of the arrays.

Use OOP if you want to use OOP. Don't use OOP if you don't want to use OOP😄

 
Vladislav Boyko #:
There is nothing stopping you from calculating indicator values yourself.

But in this case there is a lot more work involved. Especially in MQL5 Expert Advisors, where there are no ready-made arrays with price data and, in addition to emulating indicator buffers, you need to take care of correct copying of bar prices.

 
Vladislav Boyko #:

There is nothing stopping you from calculating indicator values yourself. You create dynamic arrays and calculate indicator values for each bar, plus manage the sizes of the arrays.

Use OOP if you want to use OOP. Don't use OOP if you don't want to use OOP😄


That was not the point

Spoiler alert:

https://www.mql5.com/en/articles/2574
 
Tobias Johannes Zimmer #:

That was not the point

Spoiler alert:

https://www.mql5.com/en/articles/2574
What has the standard library to do with loading custom indicators??

I don't get it.

PS: The article you linked is not exactly a sophisticated approach, in my humble opinion...
 
Dominik Egert #:
What has the standard library to do with loading custom indicators??

I don't get it.

PS: The article you linked is not exactly a sophisticated approach, in my humble opinion...

Okay, can you explain? I figured it was necessary if I wanted to use the CExpertSignal system to create EAs from custom indicators with the wizard system.

class CSignalRSI : public CExpertSignal
  {
protected:
   CiRSI             m_rsi;            // object-oscillator
   //--- adjusted parameters
   int               m_periodRSI;      // the "period of calculation" parameter of the oscillator
   ENUM_APPLIED_PRICE m_applied;       // the "prices series" parameter of the oscillator
   //--- "weights" of market models (0-100)
   int               m_pattern_0;      // model 0 "the oscillator has required direction"
   int               m_pattern_1;      // model 1 "reverse behind the level of overbuying/overselling"
   int               m_pattern_2;      // model 2 "failed swing"
   int               m_pattern_3;      // model 3 "divergence of the oscillator and price"
   int               m_pattern_4;      // model 4 "double divergence of the oscillator and price"
   int               m_pattern_5;      // model 5 "head/shoulders"

...


It uses classes like CiRSI etc. These have the same structure, no?

//+------------------------------------------------------------------+
//| Class CiRSI.                                                     |
//| Purpose: Class of the "Relative Strength Index" indicator.       |
//|          Derives from class CIndicator.                          |
//+------------------------------------------------------------------+
class CiRSI : public CIndicator
  {
protected:
   int               m_ma_period;
   int               m_applied;

public:
                     CiRSI(void);
                    ~CiRSI(void);
   //--- methods of access to protected data
   int               MaPeriod(void)        const { return(m_ma_period); }
   int               Applied(void)         const { return(m_applied);   }
   //--- method of creation
   bool              Create(const string symbol,const ENUM_TIMEFRAMES period,const int ma_period,const int applied);
   //--- methods of access to indicator data
   double            Main(const int index) const;
   //--- method of identifying
   virtual int       Type(void) const { return(IND_RSI); }

protected:
   //--- methods of tuning
   virtual bool      Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam &params[]);
   bool              Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int ma_period,const int applied);
  };

All he is doing is mimic the structure, just with iCustom, right? What else should be done?

 
Tobias Johannes Zimmer #:

Okay, can you explain? I figured it was necessary if I wanted to use the CExpertSignal system to create EAs from custom indicators with the wizard system.


It uses classes like CiRSI etc. These have the same structure, no?

All he is doing is mimic the structure, just with iCustom, right? What else should be done?

What else should be done is a good question...

There has been some discussion about using indicators in EAs, the conclusion was more or less, it is best to implement them directly into the EA, without using iCustom. Well, of course, only if that is possible.

Running indicators in iCustom has some significant drawbacks. One is they all run in one thread, and this thread can actually delay the execution of the indicators.

Also, there is a known bug with iXXX functions, that is, on first tick of a new period, they don't get updated.

Also the amount of resources is much easier to control in your EA code, as it is for iXXX functions.

The list of advantages goes on for implementing the indicators yourself. Aside from the effect you actually understand how they work.


 
Dominik Egert #:
What else should be done is a good question...

There has been some discussion about using indicators in EAs, the conclusion was more or less, it is best to implement them directly into the EA, without using iCustom. Well, of course, only if that is possible.

Where is this conclusion argued ?

My posts (see the search engine) and opinion are exactly the reverse : in general, it's not worth the trouble to implement indicators directly in the EA.

 
Dominik Egert #:
What else should be done is a good question...

There has been some discussion about using indicators in EAs, the conclusion was more or less, it is best to implement them directly into the EA, without using iCustom. Well, of course, only if that is possible.

Running indicators in iCustom has some significant drawbacks. One is they all run in one thread, and this thread can actually delay the execution of the indicators.

Also, there is a known bug with iXXX functions, that is, on first tick of a new period, they don't get updated.

Also the amount of resources is much easier to control in your EA code, as it is for iXXX functions.

The list of advantages goes on for implementing the indicators yourself. Aside from the effect you actually understand how they work.


Alain Verleyen #:

Where is this conclusion argued ?

My posts (see the search engine) and opinion are exactly the reverse : in general, it's not worth the trouble to implement indicators directly in the EA.

Vladislav Boyko #:

There is nothing stopping you from calculating indicator values yourself. You create dynamic arrays and calculate indicator values for each bar, plus manage the sizes of the arrays.

Use OOP if you want to use OOP. Don't use OOP if you don't want to use OOP😄

I respect all your opinions, but I think I think I chose a pretty simple and straightforward question. Is there a way to get indicator values into an EA with OOP that doesn't use iCustom or CopyBuffer? An Indicator is a certain entity in MQL and calling one is a fairly obvious task. I would like to remind you that I did not ask if an indicator calculation could be done directly in an EA, although I am aware of the restrictions of mql indicator thread management, as well as the obvious flaws of CiIndicator classes like the DEFAULT_BUFFER_SIZE of 1024.
While it is interesting to have experienced developers talk about such details please respect that this was not the question asked.

 
Tobias Johannes Zimmer #:
Is there a way to get indicator values into an EA with OOP that doesn't use iCustom or CopyBuffer?

I don’t understand why you are focusing on OOP in your question. What does OOP have to do with it, what does it change?

 
Tobias Johannes Zimmer #:

I respect all your opinions, but I think I think I chose a pretty simple and straightforward question. Is there a way to get indicator values into an EA with OOP that doesn't use iCustom or CopyBuffer? An Indicator is a certain entity in MQL and calling one is a fairly obvious task. I would like to remind you that I did not ask if an indicator calculation could be done directly in an EA, although I am aware of the restrictions of mql indicator thread management, as well as the obvious flaws of CiIndicator classes like the DEFAULT_BUFFER_SIZE of 1024.
While it is interesting to have experienced developers talk about such details please respect that this was not the question asked.

I guess the answer is sort of. At least that would represent my opinion.

If the indicator declares the OnCalculate function with the keyword export, you could load the indicator .ex5 file as a library.

But your indicator code needs to be adjusted heavily to actually work.

So, with source code available, yes.

Without source code, you can only use iCustom as possible solution.