#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots 5
#property indicator_label1 "long"
#property indicator_type1 DRAW_LINE
#property indicator_color1 Red
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
#property indicator_label2 "small"
#property indicator_type2 DRAW_LINE
#property indicator_color2 Yellow
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
#property indicator_label5 "long1"
#property indicator_type5 DRAW_LINE
#property indicator_color5 Green
#property indicator_style5 STYLE_SOLID
#property indicator_width5 1
#property indicator_label3 "up"
#property indicator_type3 DRAW_ARROW
#property indicator_color3 Red
#property indicator_style3 STYLE_SOLID
#property indicator_width3 1
#property indicator_label4 "down"
#property indicator_type4 DRAW_ARROW
#property indicator_color4 Red
#property indicator_style4 STYLE_SOLID
#property indicator_width4 1
input
int longma
=10;
input
int smallma
=10;
input
int longma1
=2;
double longBuffer
[];
double smallBuffer
[];
double longBuffer1
[];
double upBuffer
[];
double downBuffer
[];
int longma_handle
;
int smallma_handle
;
int longma_handle1
;
int OnInit()
{
SetIndexBuffer(0,longBuffer
,INDICATOR_DATA
);
SetIndexBuffer(1,smallBuffer
,INDICATOR_DATA
);
SetIndexBuffer(2,upBuffer
,INDICATOR_DATA
);
SetIndexBuffer(3,downBuffer
,INDICATOR_DATA
);
SetIndexBuffer(4,longBuffer1
,INDICATOR_DATA
);
PlotIndexSetInteger(2,PLOT_DRAW_TYPE
,DRAW_ARROW
);
PlotIndexSetInteger(3,PLOT_DRAW_TYPE
,DRAW_ARROW
);
PlotIndexSetInteger(2,PLOT_ARROW
,1001);
PlotIndexSetInteger(3,PLOT_ARROW
,1002);
longma_handle
=iMA(Symbol(),0,longma
,0,MODE_SMA
,PRICE_HIGH
);
smallma_handle
=iMA(Symbol(),0,smallma
,0,MODE_SMA
,PRICE_LOW
);
longma_handle1
=iMA(Symbol(),0,longma1
,0,MODE_SMA
,PRICE_CLOSE
);
return(0);
}
int OnCalculate(const int rates_total
,
const int prev_calculated
,
const datetime
& time
[],
const double& open
[],
const double& high
[],
const double& low
[],
const double& close
[],
const long& tick_volume
[],
const long& volume
[],
const int& spread
[])
{
int malong
=CopyBuffer(longma_handle
,0,0,rates_total
,longBuffer
);
int masmall
=CopyBuffer(smallma_handle
,0,0,rates_total
,smallBuffer
);
int malong1
=CopyBuffer(longma_handle1
,0,0,rates_total
,longBuffer1
);
for(int i
=10;i
<rates_total
;i
++)
{
if((longBuffer
[i
-1]>longBuffer1
[i
-1])&&(longBuffer
[i
]<longBuffer1
[i
]))
{
upBuffer
[i
]=longBuffer
[i
];
if(i
==prev_calculated
)
{
Alert("up");
SendMail("EURUSD看多","上穿10天最高价均线");
SendNotification("EURUSD看多");
}
}
if((smallBuffer
[i
-1]<longBuffer1
[i
-1])&&(smallBuffer
[i
]>longBuffer1
[i
]))
{
downBuffer
[i
]=longBuffer1
[i
];
if(i
==prev_calculated
)
{
Alert("down");
SendMail("EURUSD看空","下穿10天最低价均线");
SendNotification("EURUSD看空");
}
}
}
return(rates_total
);
}
转载请注明原文地址: https://mac.8miu.com/read-492429.html