Hi Guys,
Could someone please look at this code.
It is to display whether MAs are in correct order for a up trend or down trend.
When the chart is at the end (most recent bar visible) the indicator window is blank. As you scroll left and right the indicator will become visible.
I am not sureif I have done something wronf here.
Thanks
Steve
//+------------------------------------------------------------------+
//| iMAOnArray.mq4 |
//| Coders Guru |
//| http://www.metatrader.info |
//+------------------------------------------------------------------+
#property copyright "Coders Guru"
#property link "http://www.metatrader.info"
#property indicator_separate_window
#property indicator_color1 LawnGreen
#property indicator_color2 DarkBlue
double ExtMapBuffer1[];
double ma30[];
double ma35[];
double ma40[];
double ma45[];
double ma50[];
double ma60[];
int init()
{
IndicatorBuffers(7);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ma30);
SetIndexBuffer(2,ma35);
SetIndexBuffer(3,ma40);
SetIndexBuffer(4,ma45);
SetIndexBuffer(5,ma50);
SetIndexBuffer(6,ma60);
return;
}
int deinit()
{
return(0);
}
int start()
{
int bar, limit;
int counted_bars=IndicatorCounted();
//int counted_bars = 50;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-IndicatorCounted();
//limit = 50;
for(bar=0; bar<limit; bar++)
{
ma30[bar] = iMA(NULL,0,30,0,MODE_EMA,PRICE_MEDIAN,bar);
ma35[bar] = iMA(NULL,0,35,0,MODE_EMA,PRICE_MEDIAN,bar);
ma40[bar] = iMA(NULL,0,40,0,MODE_EMA,PRICE_MEDIAN,bar);
ma45[bar] = iMA(NULL,0,45,0,MODE_EMA,PRICE_MEDIAN,bar);
ma50[bar] = iMA(NULL,0,50,0,MODE_EMA,PRICE_MEDIAN,bar);
ma60[bar] = iMA(NULL,0,60,0,MODE_EMA,PRICE_MEDIAN,bar);
}
/*
for(bar=0; bar<limit; bar++)
ma30[bar] = iMA(NULL,0,30,0,MODE_EMA,PRICE_MEDIAN,bar);
for(bar=0; bar<limit; bar++)
ma35[bar] = iMA(NULL,0,35,0,MODE_EMA,PRICE_MEDIAN,bar);
for(bar=0; bar<limit; bar++)
ma40[bar] = iMA(NULL,0,40,0,MODE_EMA,PRICE_MEDIAN,bar);
for(bar=0; bar<limit; bar++)
ma45[bar] = iMA(NULL,0,45,0,MODE_EMA,PRICE_MEDIAN,bar);
for(bar=0; bar<limit; bar++)
ma50[bar] = iMA(NULL,0,50,0,MODE_EMA,PRICE_MEDIAN,bar);
for(bar=0; bar<limit; bar++)
ma60[bar] = iMA(NULL,0,60,0,MODE_EMA,PRICE_MEDIAN,bar);
*/
for(bar=0; bar<limit; bar++)
{
if(ma30[bar]>ma35[bar] && ma35[bar]>ma40[bar] && ma40[bar]>ma45[bar] && ma45[bar]>ma50[bar] && ma50[bar]>ma60[bar])
{
ExtMapBuffer1[bar] = 1;
}
else
{
if(ma30[bar]<ma35[bar] && ma35[bar]<ma40[bar] && ma40[bar]<ma45[bar] && ma45[bar]<ma50[bar] && ma50[bar]<ma60[bar])
{
ExtMapBuffer1[bar] = -1;
}
else
{
ExtMapBuffer1[bar] = 0;
}
}
}
return(0);
}
Could someone please look at this code.
It is to display whether MAs are in correct order for a up trend or down trend.
When the chart is at the end (most recent bar visible) the indicator window is blank. As you scroll left and right the indicator will become visible.
I am not sureif I have done something wronf here.
Thanks
Steve
//+------------------------------------------------------------------+
//| iMAOnArray.mq4 |
//| Coders Guru |
//| http://www.metatrader.info |
//+------------------------------------------------------------------+
#property copyright "Coders Guru"
#property link "http://www.metatrader.info"
#property indicator_separate_window
#property indicator_color1 LawnGreen
#property indicator_color2 DarkBlue
double ExtMapBuffer1[];
double ma30[];
double ma35[];
double ma40[];
double ma45[];
double ma50[];
double ma60[];
int init()
{
IndicatorBuffers(7);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ma30);
SetIndexBuffer(2,ma35);
SetIndexBuffer(3,ma40);
SetIndexBuffer(4,ma45);
SetIndexBuffer(5,ma50);
SetIndexBuffer(6,ma60);
return;
}
int deinit()
{
return(0);
}
int start()
{
int bar, limit;
int counted_bars=IndicatorCounted();
//int counted_bars = 50;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-IndicatorCounted();
//limit = 50;
for(bar=0; bar<limit; bar++)
{
ma30[bar] = iMA(NULL,0,30,0,MODE_EMA,PRICE_MEDIAN,bar);
ma35[bar] = iMA(NULL,0,35,0,MODE_EMA,PRICE_MEDIAN,bar);
ma40[bar] = iMA(NULL,0,40,0,MODE_EMA,PRICE_MEDIAN,bar);
ma45[bar] = iMA(NULL,0,45,0,MODE_EMA,PRICE_MEDIAN,bar);
ma50[bar] = iMA(NULL,0,50,0,MODE_EMA,PRICE_MEDIAN,bar);
ma60[bar] = iMA(NULL,0,60,0,MODE_EMA,PRICE_MEDIAN,bar);
}
/*
for(bar=0; bar<limit; bar++)
ma30[bar] = iMA(NULL,0,30,0,MODE_EMA,PRICE_MEDIAN,bar);
for(bar=0; bar<limit; bar++)
ma35[bar] = iMA(NULL,0,35,0,MODE_EMA,PRICE_MEDIAN,bar);
for(bar=0; bar<limit; bar++)
ma40[bar] = iMA(NULL,0,40,0,MODE_EMA,PRICE_MEDIAN,bar);
for(bar=0; bar<limit; bar++)
ma45[bar] = iMA(NULL,0,45,0,MODE_EMA,PRICE_MEDIAN,bar);
for(bar=0; bar<limit; bar++)
ma50[bar] = iMA(NULL,0,50,0,MODE_EMA,PRICE_MEDIAN,bar);
for(bar=0; bar<limit; bar++)
ma60[bar] = iMA(NULL,0,60,0,MODE_EMA,PRICE_MEDIAN,bar);
*/
for(bar=0; bar<limit; bar++)
{
if(ma30[bar]>ma35[bar] && ma35[bar]>ma40[bar] && ma40[bar]>ma45[bar] && ma45[bar]>ma50[bar] && ma50[bar]>ma60[bar])
{
ExtMapBuffer1[bar] = 1;
}
else
{
if(ma30[bar]<ma35[bar] && ma35[bar]<ma40[bar] && ma40[bar]<ma45[bar] && ma45[bar]<ma50[bar] && ma50[bar]<ma60[bar])
{
ExtMapBuffer1[bar] = -1;
}
else
{
ExtMapBuffer1[bar] = 0;
}
}
}
return(0);
}
Attached File(s)
zb GMMA LT.ex4
4 KB
|
168 downloads