ima on array problem can u help me guys?

 

hi to all,

what i want to do is, a custım indicator that has two color .one variable is ima(...)-ima(..).this is macd u know.The second variable is imaonArray of macd.if macd is above the imaonarray line color becomes green.İf below maCD LİNE İS RED.tHİS İS AN EASY TASK BUT i think i miss something.Here is the code;




#property indicator_buffers 3
#property indicator_separate_window
//----
#property indicator_color1 Red //macd
#property indicator_color2 SteelBlue //signal
#property indicator_color3 Lime

//---- buffers
double Buffer1[]; //macd
double Buffer2[]; //signal
double Buffer3[];
//----
extern int FastEMA=9;
extern int SlowEMA=64;
extern int SignalSMA=112;

//----
int limit=0;
int i=0;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
//---- indicators


SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);//macd
SetIndexStyle(1,DRAW_NONE,STYLE_SOLID);//signal
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,3);

//
SetIndexBuffer(0,Buffer1);
SetIndexBuffer(1,Buffer2);
SetIndexBuffer(2,Buffer3);

//
SetIndexDrawBegin(1,SignalSMA);
//
IndicatorShortName("trendy-2");
//
SetIndexLabel(0,"Kımızı");
SetIndexLabel(1,"Mavi");
SetIndexLabel(2,"yeni");
//
ArraySetAsSeries(Buffer1, true);
ArraySetAsSeries(Buffer2, true);
ArraySetAsSeries(Buffer3, true);

ArrayResize(Buffer1[i],Bars);
ArrayResize(Buffer2[i],Bars);
ArrayResize(Buffer3[i],Bars);
//----
return(0);
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{

return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{

//----Standart bar hesabı------------------------
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);//---- check for possible errors
if(counted_bars>0) counted_bars--;//---- last counted bar will be recounted
limit=Bars-counted_bars;

//----Ana Hesaplama Döngüsü-----------------------
for(i=0; i<limit; i++)//--
Buffer1[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//----

for(i=0; i<limit; i++)//-
Buffer3[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

for(i=0; i<limit; i++)//-
Buffer2[i]=iMAOnArray(Buffer1,Bars,SignalSMA,0,MODE_SMA,i);



for(i=0; i<limit; i++)
{
if (Buffer1[i-1]>Buffer2[i-1] )
{
Buffer2[i] = EMPTY_VALUE;
Buffer1[i] = EMPTY_VALUE;
}

else if (Buffer1[i-1]<Buffer2[i-1] )
{
Buffer2[i] = EMPTY_VALUE;
Buffer3[i] = EMPTY_VALUE;
}

is the an easy way to do this.Pls help me this is my homework guys