icustom indicator that can pass a variable back to EA

 
Can custom indicators return a variable (parameter) back to the calling EA. I know how to send parameters from the EA to the indicator using icustom, but how how can I pass a new variable (parameter) from the indicator to the EA?
 

The purpose of iCustom() is to get a value from an indicator, usually the value of one of the indicator buffers. The parameters you send using iCustom() are to tell the indicator which indicator line you want the value of, and which settings the indicator should use when calculating the value to be returned to the EA. If you want to retrieve a value from the indicator which is not held in one of the indicator buffers, create a new buffer in the indicator and put the values you want in it then retrieve the values from that buffer from the EA using iCustom()

 
bjoost:
Can custom indicators return a variable (parameter) back to the calling EA. I know how to send parameters from the EA to the indicator using icustom, but how how can I pass a new variable (parameter) from the indicator to the EA?
Have a read of this thread: https://www.mql5.com/en/forum/138577
 
SDC:

The purpose of iCustom() is to get a value from an indicator, usually the value of one of the indicator buffers. The parameters you send using iCustom() are to tell the indicator which indicator line you want the value of, and which settings the indicator should use when calculating the value to be returned to the EA. If you want to retrieve a value from the indicator which is not held in one of the indicator buffers, create a new buffer in the indicator and put the values you want in it then retrieve the values from that buffer from the EA using iCustom()

Thank you. that makes sense. The indicator has 4 buffers:

SetIndexBuffer(0, bullishDivergence);
SetIndexBuffer(1, bearishDivergence);

SetIndexBuffer(2, macd);

SetIndexBuffer(3, signal);

You say I should add a 5th, lets says: SetIndexBuffer(4, RetrieveValue);

My indicator code would move a value to RetrieveValue:

double x = 123;

x=RetrieveValue;

My EA ....

then the iCustom would be:

double valueBuffer4=iCustom(NULL, 0, "MACD_Divergence",RetrieveValue,4,0);

in theory valueBuffer 4 would be = 123.

Do I have it write?


Thanks again

 
bjoost:

Thank you. that makes sense. The indicator has 4 buffers:

SetIndexBuffer(0, bullishDivergence);
SetIndexBuffer(1, bearishDivergence);

SetIndexBuffer(2, macd);

SetIndexBuffer(3, signal);

You say I should add a 5th, lets says: SetIndexBuffer(4, RetrieveValue);

My indicator code would move a value to RetrieveValue:

double x = 123;

RetrieveValue=x;

My EA ....

then the iCustom would be:

double valueBuffer4=iCustom(NULL, 0, "MACD_Divergence",RetrieveValue,4,0);

in theory valueBuffer 4 would be = 123.

Do I have it write?


Thanks again


Reason: