Conversion of Indicator into EA

 
Hi All,

I got an issue with the EA of RSI and MA...

I got the indicator working properly... All I want is to convert it into EA...

I tried a couple of things. IndicatorCounted() is not working in EA, so I tried to hard-code the values of the for loop (bar=0; bar<15; bar++), I was getting correct RSI, but SMA is not giving corect values...

I'm attaching the code for SMA crossing the RSI...

So could someone please help me to convert this Indicator into EA.

***************************************************************************************************************************************
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LawnGreen
#property indicator_color2 DarkBlue

double ExtMapBuffer1[];
double ExtMapBuffer2[];

int init()
{
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(1,ExtMapBuffer2);
return(0);
}

int deinit()
{
return(0);
}

int start()
{
int bar, limit;

int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-IndicatorCounted();


for(bar=0; bar<limit; bar++)
ExtMapBuffer1[bar] = iRSI(NULL,0,14,PRICE_TYPICAL,bar);

for(bar=0; bar<limit; bar++)
ExtMapBuffer2[bar]=iMAOnArray(ExtMapBuffer1,Bars,14,0,MODE_SMA,bar);

return(0);
}

***************************************************************************************************************************************

Thanks & Regards,
Ganesh
 

Hello,

You can use the result of your indicator in your EA with the function iCustom() : https://docs.mql4.com/indicators/iCustom

 
Jacques366:

Hello,

You can use the result of your indicator in your EA with the function iCustom() : https://docs.mql4.com/indicators/iCustom

Hi Jacques,

Thanks for the quick response...

Could you please be specific of how to use that.. With some example...

I'm new to mql4 coding... will it return double value or array kind of thing also....


Thanks in advance...

 
Jacques366:

Hello,

You can use the result of your indicator in your EA with the function iCustom() : https://docs.mql4.com/indicators/iCustom

Hi Jacques,

Got the code working.. Thanks alot for the help...

Ganesh

Reason: