Download MetaTrader 5

How to programmatically get the value of an indicator which is applied to the value of another indicator

To add comments, please log in or register
Find out how to install MetaTrader on Mac OS
Derk Wehler
238
Derk Wehler 2014.12.30 09:08 

I have never found a way to do this; does anyone know if there is a method.

For example, calling one can put an RSI on a chart, then an moving average of that RSI.  In code, how do I get the value of that MA on the RSI?

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.12.30 09:18  
Never heard of iCustom ?
Keith Watford
Moderator
9624
Keith Watford 2014.12.30 09:26  
DerkWehler:

I have never found a way to do this; does anyone know if there is a method.

For example, calling one can put an RSI on a chart, then an moving average of that RSI.  In code, how do I get the value of that MA on the RSI?

 

Get the values of the RSI with iRSI and store in a buffer or array. Then use iMAOnArray
Derk Wehler
238
Derk Wehler 2014.12.30 09:36  
deysmacro:
deysmacro:
Never heard of iCustom ?

Of course, but I am not sure how that allows me to get any indicators value based on another ind's data.  Perhaps you can show an example of how to do so, using iCustom of "Ind1" that is based on the data from "Ind2"?
Derk Wehler
238
Derk Wehler 2014.12.30 09:39  
GumRai:
Get the values of the RSI with iRSI and store in a buffer or array. Then use iMAOnArray

The problem here is that was just an example.  I am not using moving average as one of the two indicators.

I am using a custom ind (QQE) and then an RSI of that ind, and then a moving average of the RSI.

So I suppose if I can learn how to get the RSI of the QQE, then I already know how to do the MA.... 

Keith Watford
Moderator
9624
Keith Watford 2014.12.30 09:58  
DerkWehler:

The problem here is that was just an example.  I am not using moving average as one of the two indicators.

I am using a custom ind (QQE) and then an RSI of that ind, and then a moving average of the RSI.

So I suppose if I can learn how to get the RSI of the QQE, then I already know how to do the MA.... 

Then get the values of the indicator with iCustom and save in a buffer or array

Get the RSI with iRSIOnArray

and the MA with iMAOnArray 

Derk Wehler
238
Derk Wehler 2014.12.30 10:13  
GumRai:

Then get the values of the indicator with iCustom and save in a buffer or array

Get the RSI with iRSIOnArray

and the MA with iMAOnArray 

Ok, thank you.  I didn't know / had forgotten there was an RSIOnArray.

Generally though, is there no way to do it with 2 inds that do not have ...OnArray functions?

Keith Watford
Moderator
9624
Keith Watford 2014.12.30 10:47  
DerkWehler:

Ok, thank you.  I didn't know / had forgotten there was an RSIOnArray.

Generally though, is there no way to do it with 2 inds that do not have ...OnArray functions?

 

Of course, but you will have to write/adapt the indicator code to suit the data that you are working on
Alain Verleyen
Moderator
30737
Alain Verleyen 2014.12.30 16:10  
DerkWehler:

Ok, thank you.  I didn't know / had forgotten there was an RSIOnArray.

Generally though, is there no way to do it with 2 inds that do not have ...OnArray functions?

 

Only with mql5, not with mql4.
Derk Wehler
238
Derk Wehler 2014.12.31 01:43  
GumRai:
Of course, but you will have to write/adapt the indicator code to suit the data that you are working on

Thank you for the aid.  One more thing if you can help please; ArraySetAsSeries has always been a bit confusing to me, and although I have searched for samples, I haven't found one to really clear it up...

Consider the issue above.  In order to get my arrays filled correctly, do I need to do this:

// Fill QQE Buffer

for (int i=limit; i > 0; i--)

        BufferQQE[i] = iCustom(NULL, 0, "QQE Adv", QQE_SF, QQE_RSI, QQE_WP,   0, i);

 

// Fill RSI Buffer

ArraySetAsSeries(BufferQQE, true);

for (int i=limit; i > 0; i--)

        BufferRSI[i] = iRSIOnArray(BufferQQE, 0, RSI_Period, i);

ArraySetAsSeries(BufferQQE, false);

 

// Fill MA Buffer

ArraySetAsSeries(BufferRSI, true);

for (int i=limit; i > 0; i--)

        BufferMA[i] = iMAOnArray(BufferRSI, 0, MA_Period, MA_Shift, MA_Method, i);

ArraySetAsSeries(BufferRSI, false);

 

For some reason I do not think I have the hang of this quite right, so clarification appreciated.

When all done, I would like the arrays all correct and in standard right-to-left indexing. 

 

Keith Watford
Moderator
9624
Keith Watford 2014.12.31 05:32  

I don't see why you would need to change the series on a buffer.

Buffers are automatically re-sized to the number of bars and when a new bar is formed there is a new position [0]. The old pos[0] is shifted to pos[1] etc.

By using  ArraySetAsSeries(BufferRSI, false), on the next new bar tick, the new position will be added at the other end, at pos[Bars-1] and the loop will be overwriting the same positions every time ( [limit] to [0] ) because you reset the buffer to TimeSeries

12
To add comments, please log in or register