[MT4指标]收盘价在均线上报警指标高手帮忙改下
本程序用于判断收盘价格突破ma15提示箭头并声音报警,向上破ma15出现蓝色箭头,向下破ma15出现红色箭头
ma参数可调,目前定义是15均线,可根据自己要求修改
ma-alert.mq4和ma-alert.ex4文件放在mt4所在目录\experts\indicators目录下
但是没有声音.谢谢.不胜感激.
//+------------------------------------------------------------------+
//| Custom ma-alert.mq4 |
//| Copyright 2007, 暗袖盈香 |
//| 领域外汇论坛 http://www.fxxxt.cn |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue //渣,蓝色箭头
#property indicator_color2 Red //沽,红色箭头
extern int shift = 0;
extern int ma_period = 15; //ma参数值
double ma1; //ma的值
double buy, sell;
int init()
{
//---- indicators
SetIndexStyle (0, DRAW_ARROW, EMPTY, 1);
SetIndexArrow (0, 233);
SetIndexBuffer (0, buy);
SetIndexEmptyValue (0, 0.0);
SetIndexStyle (1, DRAW_ARROW, EMPTY, 1);
SetIndexArrow (1, 234);
SetIndexBuffer (1, sell);
SetIndexEmptyValue (1, 0.0);
//----
return(0);
}
int start()
{
for(int i = Bars - 1; i >= 0; i --)
{
ma1 = iMA(Symbol() , NULL , ma_period , 0 , MODE_SMA , PRICE_CLOSE , i );
buy = 0;
sell = 0;
//
if(Close > ma1 && Open < ma1) //当前根烛开盘低于已定义均线,收盘高于已定义均线
{
buy = Low - 20*Point;
}
if(Close < ma1 && Open > ma1) //当前根烛开盘高于已定义均线,收盘低于已定义均线
{
sell = High + 20*Point;
}
}
}ma-alert.mq4