我下载了一个均线交叉报警指示指标,但是有两个问题不能解决,第一是箭头指示和K线靠的太近,看不清,第二是均线交叉的指示比交叉晚了三根K线,下面是指标源码,那位大侠帮我改改吧,先谢谢了!
//+------------------------------------------------------------------+
//| EMA-Crossover_Signal.mq4 |
//|
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 DodgerBlue
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Yellow
double CrossUp[];
double CrossDown[];
double MAF[];
double MAS[];
extern bool Alert_X=true;
extern int FasterMode = 1; //0=sma, 1=ema, 2=smma, 3=lwma
extern int FasterMA = 5;
extern int SlowerMode = 1; //0=sma, 1=ema, 2=smma, 3=lwma
extern int SlowerMA = 10;
static double UP_Alert,DO_Alert;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, 2,5);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, 2,5);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
SetIndexBuffer(2, MAF);
SetIndexBuffer(3, MAS);
SetIndexStyle(2, DRAW_LINE);
SetIndexStyle(3, DRAW_LINE);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete(\"onefx_label0\");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, i, counter;
double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
double Range;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars0) counted_bars--;
limit=Bars-counted_bars;
for(i = 0; i MAS[i+1] && MAF[i+2] < MAS[i+2])
{
CrossUp = Open;//Low - Range*0.5;
}
if (MAF < MAS && MAF[i+1] < MAS[i+1] && MAF[i+2] > MAS[i+2])
{
CrossDown = Open;//High + Range*0.5;
}
}
if (Alert_X==false)
{
DO_Alert=Time[0];
UP_Alert=Time[0];
}
if (UP_Alert!=Time[0] && MAF[0] > MAS[0] && MAF[1] > MAS[1] && MAF[2] < MAS[2])
{
Alert(Symbol()+\" \"+Period()+\" MA-Crossover_Signal \"+FasterMA+\" 金叉 \"+SlowerMA);
UP_Alert=Time[0];
}
if (DO_Alert!=Time[0] && MAF[0] < MAS[0] && MAF[1] < MAS[1] && MAF[2] > MAS[2])
{
Alert(Symbol()+\" \"+Period()+\" MA-Crossover_Signal \"+FasterMA+\" 死叉\"+SlowerMA);
DO_Alert=Time[0];
}
return(0);
}
//+------------------------------------------------------------------+ |