Generating Numeric Values from Indicator Arithmetic in EA coding

 

Hello people

Here's a block of code of an indicator I am trying to convert into EA format

--------------------------------------------------------------------------------------------------------------------------------------------------

int limit;

int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd mirror counted in the 1-st buffer
for(int i=0; i<limit; i++)

MacdBuffer[i]=iMA(NULL,0,PeriodeEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,PeriodeEMA,0,MODE_EMA,PRICE_OPEN,i);

---------------------------------------------------------------------------------------------------------------------------------------------------

The MacdBuffer returns a numeric value, and it is this value I want to replicate in EA code to be used as part of a buy/sell signal generation and also for exits;

for example if at close of bar ''Macdbuffer'' is 0.01 intiate buy, and so on...

any ideas

 
use iCustom() if it'S a custom indicator
 
zzuegg:
use iCustom() if it'S a custom indicator

Forgive this question, i'm a coder newbie, i've tried using iCustom ; but I dont fully understand the use of this function...when I call the indicator how do i set the condition to interpret its numeric value, here's my own code

Msig = iCustom(NULL,0,"MACD_Mirror",20,9,0,0);

then in signal part of code...if (Msig == 0.002 && ......//Buy ------------the 20,9 are the indicator variables..

 

looks got, but the probabillity that the indicator return 0.002 is very small, when working with floating point numbers you should never check for equality. instead you should use > or <, and introduce a treshold.

something like:

double treshold=0.0001;
Msig=iCustom()....
if(Msig< 0.002+treshold &&Msig>0.002-treshold){

}
 
zzuegg:

looks got, but the probabillity that the indicator return 0.002 is very small, when working with floating point numbers you should never check for equality. instead you should use > or <, and introduce a treshold.

something like:



Thanks a lot for your help, only experience can teach that, I'm going to work on it right now
Reason: