Trabalho concluído
Termos de Referência
i need to convert the attached indicator to expert
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 5
#property indicator_width2 5
#property indicator_minimum 0
extern int MA_1_Bars = 20;
extern int MA_2_Bars = 5;
double up[];
double down[];
double MA_1[];
double MA_2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators buffer used in calculation
IndicatorBuffers(4);
SetIndexBuffer(0,up);
SetIndexBuffer(1,down);
SetIndexBuffer(2,MA_1);
SetIndexBuffer(3,MA_2);
//----indicator drawing style
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
//----Data window & Index Label
SetIndexLabel(0,"up");
SetIndexLabel(1,"down");
//----indicator begin & digit number used at calculation
SetIndexDrawBegin(0,1);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for errors
if(counted_bars<0) return(-1);
//---- recount the last Bar
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//--- main loop
for(int ii=0; ii<limit;ii++)
MA_1[ii] = iMA(NULL,0,MA_1_Bars,0,MODE_LWMA,PRICE_CLOSE,ii);
for(int i=0; i<limit;i++)
MA_2[i] = iMAOnArray(MA_1,0,MA_2_Bars,0,MODE_LWMA,i);
for(int y=0; y<limit;y++)
if(MA_1[y] > MA_2[y])
up[y] = 1;
else
if(MA_1[y] < MA_2[y])
down[y] = 1;
//----
return(0);
}
//+------------------------------------------------------------------+