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

345

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?

1952

Never heard of iCustom ?
Moderator
28198

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
345

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"?
345

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....

Moderator
28198

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

345

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?

Moderator
28198

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
41040

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.
345

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.

Moderator
28198

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