变色均线指标
//+------------------------------------------------------------------+//| Vinin-LRMA.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Red
#property indicator_color3 Green
extern int period=250;
extern int price=0;
extern int Shift=0;
//---- buffers
double BufferGreen[];
double BufferYellow[];
double BufferRed[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int i;
for(i=0;i<3;i++)
{
SetIndexStyle(i,DRAW_LINE);
SetIndexDrawBegin(i,period);
SetIndexShift(i,Shift);
}
SetIndexBuffer(0,BufferYellow);
SetIndexBuffer(1,BufferGreen);
SetIndexBuffer(2,BufferRed);
return(0);
}//int init()
//+------------------------------------------------------------------+
int start()
{
double tmp1,tmp2,tmp3;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
if(counted_bars==0) limit-=1+1;
for(int i=limit;i>=0;i--)
{
tmp1=iMA(Symbol(),0,period,0,MODE_SMA,price,i);
tmp2=iMA(Symbol(),0,period,0,MODE_LWMA,price,i);
tmp3=3.0*tmp2-2.0*tmp1;
BufferGreen =tmp3;
BufferYellow=tmp3;
BufferRed =tmp3;
if(BufferYellow>BufferYellow)
{
BufferRed=EMPTY_VALUE;
} else if(BufferYellow<BufferYellow){
BufferGreen=EMPTY_VALUE;
} else {
BufferRed=EMPTY_VALUE;
BufferGreen=EMPTY_VALUE;
}
}
return(0);
}
//+------------------------------------------------------------------+
不错,谢了!{:1_183:} 我是来刷分的,嘿嘿 学习了,不错 学习了,不错 学习了,不错 学习了,不错 谢谢楼主分享 学习了,不错 谢谢楼主分享
页:
[1]
2