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

 
codersview:
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 DarkBluedouble 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_bars0) 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

Ganesh,

Sometimes IndicaterCounted() does not seem to work, but when you have the specific chart that you are employing this ea on open, and you manually scroll back into the history, it suddenly works. Maybe it's a very primitive way of doing it, but it has worked for me in the past.

Anyway, check out the Gomega Xray EA. It'll only be available until Sunday (March 22), but I have been testing its predecessor and I think it's awesome.

You can find the link in my profile - Website.