iCustom on array?

 

I know that for some indicators there exists an  ...OnArray() version in MQL4 (e.g.: iMAOnArray(), iRSIOnArray() etc.). I want to apply any custom indicator on an arbitrary array but it seems iCustom() doesn't support this. I'd be surprised if indicator calculation on an array of values was only possible for a few indicators.

I found a forum post that seemingly asked the same 8 years ago: https://www.mql5.com/en/forum/144659

Here, the answer given to the following: 

iCustom doesnt allow me to apply indicators on arrays.

was as follows:

#define nVALUES 20
double arr[nValues];
for(int iArr = 0; iArr < nValues; iArr++) arr[iArr] = iCustom(..., iArr);

However, this doesn't seem right to me: this doesn't input array values to iCustom but uses the array to merely control which historical candles on the chart to apply iCustom on.

To make my question even more concrete: I have a custom indicator and a custom dataset. The latter is in csv format which are read by EA. I want to apply that custom indicator on prices read from the csv. How can this be achieved? According to the documentation, iCustom doesn't support array inputs and there is no iCustomOnArray version either.

How do I apply a custom indicator to a an array?
How do I apply a custom indicator to a an array?
  • 2013.04.28
  • www.mql5.com
Suppose I want to use a custom indicator-like a certain type of moving average- on RSI values...
 

The i...OnArray() functions are coded to get their values from the provided array.

An arbitrary custom indicator has no knowledge about this. So how should a generic iCustomOnArray() be implemented?

Fetching values from an array (instead of a chart history) has to be coded within the custom indicator, and there's no way to pass an array via arguments into it.

 
lippmaje:

The i...OnArray() functions are coded to get their values from the provided array.

An arbitrary custom indicator has no knowledge about this. So how should a generic iCustomOnArray() be implemented?

Fetching values from an array (instead of a chart history) has to be coded within the custom indicator, and there's no way to pass an array via arguments into it.

I always had the impression that the i...OnArray() functions are a wrapper around the indicator file only. Is there any way to look into the code of one of these i...OnArray() functions to see how I could implement something similar for my custom indicators? I tried finding them but with no success. 

 
Levente Csibi:

I always had the impression that the i...OnArray() functions are a wrapper around the indicator file only. Is there any way to look into the code of one of these i...OnArray() functions to see how I could implement something similar for my custom indicators? I tried finding them but with no success. 

Check out my iRSIOnArray() implementation. And MovingAverages.mqh contains some MAOnArray functions.

 
lippmaje:

Check out my iRSIOnArray() implementation. And MovingAverages.mqh contains some MAOnArray functions.

Where can I find the iRSIOnArray() implementation? I tried looking for it online but with no success. Is it stored somewhere in Meta Trader's folder? 

 
In the code base.
 
lippmaje:
In the code base.
And where would that codebase be? 
As I said, "iRSIOnArray() mq4", "iRSIOnArray() codebase" etc. didn't yield any usable results
 
lippmaje: So how should a generic iCustomOnArray() be implemented?

It can't be done. Make an indicator a function inside your code and replace its inputs with passed arrays.

 
double MyDiff[];
                 
             for( int w=1; w<=10; w++)
                {              
                   double Range = Open[w]-Close[w];
                    
                   ArrayResize(MyDiff,(ArraySize(MyDiff)+1));
                   MyDiff[ArraySize(MyDiff)-1]=Range;
                   
                   w++;
                 }
                

Need help. I am trying to get array of candle ranges for the code above but its not working.

 
GDS GDS:

Need help. I am trying to get array of candle ranges for the code above but its not working.

double MyDiff[];
                 
             for( int w=1; w<=10; w++)
                {              
                   double Range = Open[w]-Close[w];
                    
                   ArrayResize(MyDiff,(ArraySize(MyDiff)+1));
                   MyDiff[ArraySize(MyDiff)-1]=Range;
                   
                   w++;
                 }

Why are you incrementing w twice in each loop?

Reason: