发新话题
打印

[MT指标及EA] 请教高手,这段源码该怎样写?

本主题由 如意 于 2008-2-9 19:18 分类

请教高手,这段源码该怎样写?

当前K线的收盘价在布林上轨或下轨时,想让当前K线在收盘时发出语音报警,现在有一段源码,下面的源码该怎样写呢?请教各位编程高手,非常感谢!
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 LightSeaGreen
#property indicator_color3 LightSeaGreen
//---- indicator parameters
extern int    BandsPeriod=20;
extern int    BandsShift=0;
extern double BandsDeviations=2.0;
extern bool   是否发出声音提示=true;
//---- buffers
double MovingBuffer[];
double UpperBuffer[];
double LowerBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MovingBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UpperBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,LowerBuffer);
//----
   SetIndexDrawBegin(0,BandsPeriod+BandsShift);
   SetIndexDrawBegin(1,BandsPeriod+BandsShift);
   SetIndexDrawBegin(2,BandsPeriod+BandsShift);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Bollinger Bands                                                  |
//+------------------------------------------------------------------+
int start()
  {

TOP

好动动啊!!!!

TOP

TOP

首先添加一个全局变量,用来避免重复报警,可以参考我的写法:
..........
int last_t = 0;

int  start()
{
   if (Time[0]>last_t)
   {
       if (High[1]>iBand(把你的参数填进来)){
                  PlaySound(这里填一个语音文件的路径);
                  last_t = Time[0];
       }
       else if (iBand(把你的参数填进来)>Low[1]){
                  PlaySound(这里填一个语音文件的路径);
                  last_t = Time[0];  
       }         
   }      
}

TOP

TOP

TOP

发新话题