请观看如何免费下载自动交易
请在Telegram上找到我们!
加入我们粉丝页
有趣的脚本?
因此发布一个链接 -
让其他人评价
喜欢这个脚本? 在MetaTrader 5客户端尝试它
显示:
1805
等级:
(23)
已发布:
2016.07.27 12:50
已更新:
2016.11.22 07:33
需要基于此代码的EA交易或指标吗?请在自由职业者服务中订购 进入自由职业者服务

信号量箭头指标, 基于经典相对强度指数振荡器远离超买和超卖区域, 并带有警报、邮件和推送通知到移动设备功能。

指标代码进行了以下修改, 以便实现报警, 邮件消息和推送通知:

  1. 介绍新的输入参数
    input uint NumberofBar=1;//信号的柱线号码
    input bool SoundON=true; //启用报警
    input uint NumberofAlerts=2;//报警次数
    input bool EMailON=false; //启用信号邮件
    input bool PushON=false; //启用推送信号通知到移动设备
    
  2. 在指标代码结尾处添加三个新函数: BuySignal(), SellSignal() 和 GetStringTimeframe()
    //+------------------------------------------------------------------+
    //| 买入信号函数                                                      |
    //+------------------------------------------------------------------+
    void BuySignal(string SignalSirname,      // 邮件和推送消息的指标名文本
                   double &BuyArrow[],        // 买入信号的指标缓存
                   const int Rates_total,     // 柱线的当前数量
                   const int Prev_calculated, // 前一时刻的柱线数量
                   const double &Close[],     // 收盘价
                   const int &Spread[])       // 点差
      {
    //---
       static uint counter=0;
       if(Rates_total!=Prev_calculated) counter=0;
    
       bool BuySignal=false;
       bool SeriesTest=ArrayGetAsSeries(BuyArrow);
       int index;
       if(SeriesTest) index=int(NumberofBar);
       else index=Rates_total-int(NumberofBar)-1;
       if(NormalizeDouble(BuyArrow[index],_Digits) && BuyArrow[index]!=EMPTY_VALUE) BuySignal=true;
       if(BuySignal && counter<=NumberofAlerts)
         {
          counter++;
          MqlDateTime tm;
          TimeToStruct(TimeCurrent(),tm);
          string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
          SeriesTest=ArrayGetAsSeries(Close);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          double Ask=Close[index];
          double Bid=Close[index];
          SeriesTest=ArrayGetAsSeries(Spread);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          Bid+=Spread[index];
          string sAsk=DoubleToString(Ask,_Digits);
          string sBid=DoubleToString(Bid,_Digits);
          string sPeriod=GetStringTimeframe(ChartPeriod());
          if(SoundON) Alert("买入信号 \n 买入价=",Ask,"\n 出售价=",Bid,"\n 当前时间=",text,"\n 品种=",Symbol()," 周期=",sPeriod);
          if(EMailON) SendMail(SignalSirname+": 买入信号报警","买入信号位于买入价="+sAsk+", 出售价="+sBid+", 日期="+text+" 品种="+Symbol()+" 周期="+sPeriod);
          if(PushON) SendNotification(SignalSirname+": 买入信号位于买入价="+sAsk+", 出售价="+sBid+", 日期="+text+" 品种="+Symbol()+" 周期="+sPeriod);
         }
    
    //---
      }
    //+------------------------------------------------------------------+
    //| 卖出信号函数                                                      |
    //+------------------------------------------------------------------+
    void SellSignal(string SignalSirname,      // 邮件和推送消息的指标名文本
                    double &SellArrow[],       // 卖出信号的指标缓存
                    const int Rates_total,     // 柱线的当前数量
                    const int Prev_calculated, // 前一时刻的柱线数量
                    const double &Close[],     // 收盘价
                    const int &Spread[])       // 点差
      {
    //---
       static uint counter=0;
       if(Rates_total!=Prev_calculated) counter=0;
    
       bool SellSignal=false;
       bool SeriesTest=ArrayGetAsSeries(SellArrow);
       int index;
       if(SeriesTest) index=int(NumberofBar);
       else index=Rates_total-int(NumberofBar)-1;
       if(NormalizeDouble(SellArrow[index],_Digits) && SellArrow[index]!=EMPTY_VALUE) SellSignal=true;
       if(SellSignal && counter<=NumberofAlerts)
         {
          counter++;
          MqlDateTime tm;
          TimeToStruct(TimeCurrent(),tm);
          string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
          SeriesTest=ArrayGetAsSeries(Close);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          double Ask=Close[index];
          double Bid=Close[index];
          SeriesTest=ArrayGetAsSeries(Spread);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          Bid+=Spread[index];
          string sAsk=DoubleToString(Ask,_Digits);
          string sBid=DoubleToString(Bid,_Digits);
          string sPeriod=GetStringTimeframe(ChartPeriod());
          if(SoundON) Alert("卖出信号 \n 买入价=",Ask,"\n 出售价=",Bid,"\n 当前时间=",text,"\n 品种=",Symbol()," 周期=",sPeriod);
          if(EMailON) SendMail(SignalSirname+": 卖出信号报警","卖出信号位于买入价="+sAsk+", 出售价="+sBid+", 日期="+text+" 品种="+Symbol()+" 周期="+sPeriod);
          if(PushON) SendNotification(SignalSirname+": 卖出信号位于买入价="+sAsk+", 出售价="+sBid+", 日期="+text+" 品种="+Symbol()+" 周期="+sPeriod);
         }
    //---
      }
    //+------------------------------------------------------------------+
    //|  获取时间帧的字符串                                               |
    //+------------------------------------------------------------------+
    string GetStringTimeframe(ENUM_TIMEFRAMES timeframe)
      {
    //----
       return(StringSubstr(EnumToString(timeframe),7,-1));
    //----
      }
    
  3. 在 OnCalculate() 模块的指标计算循环之后添加一对调用 BuySignal() 和 SellSignal() 函数。
    BuySignal("iWPRSign",BuyBuffer,rates_total,prev_calculated,close,spread);
        SellSignal("iWPRSign",SellBuffer,rates_total,prev_calculated,close,spread);
    

此处 BuyBuffer 和 SellBuffer 是指标保存买入/卖出信号的缓存名称。指标缓存区的空值必须设为零值或 EMPTY_VALUE。

假定在指标的 OnCalculate() 模块里仅调用一次 BuySignal() 和 SellSignal() 函数。

图例.1. 图表上的 iRSISignAlert 指标

图例.1. 图表上的 iRSISignAlert 指标

图例.2. 指标 iRSISignAlert。生成报警。

图例.2. 指标 iRSISignAlert。生成报警。

由MetaQuotes Ltd译自俄语
原代码: https://www.mql5.com/ru/code/15840

iDeMarkerSignAlert iDeMarkerSignAlert

信号量箭头指标, 基于经典 DeMarker 振荡器远离超买和超卖区域, 并带有警报、邮件和推送通知到移动设备功能。

iWPRSignAlert iWPRSignAlert

信号量箭头指标, 基于经典威廉姆斯百分比范围振荡器远离超买和超卖区域, 并带有警报、邮件和推送通知到移动设备功能。

Exp_Volume_Weighted_MA Exp_Volume_Weighted_MA

这款 Exp_Volume_Weighted_MA EA 基于 Volume_Weighted_MA 指标的方向变化。

Volume_Weighted_MA_HTF Volume_Weighted_MA_HTF

指标 Volume_Weighted_MA 在输入参数中有时间帧选项。