首页 技术指标 帖子

Fisher_org_v1_Sign_Alert 指标 - 提高你的交易信号通知

附件
15880.zip (4.18 KB, 下载 0次)

真实作者:

TrendLaboratory Ltd.

Fisher_org_v1 指标是一款基于 Fisher 震荡器的信号指示器,能够在超买和超卖区间发出信号,并且支持邮件和手机推送通知。

为了实现这一系列的提醒功能,代码中进行了以下更改:

  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[])       // 点差
      {
    u//---
       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("BUY signal 
     Ask=",Ask,"
     Bid=",Bid,"
     currtime=",text,"
     Symbol=",Symbol()," Period=",sPeriod);
          if(EMailON) SendMail(SignalSirname+": BUY signal alert","BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
          if(PushON) SendNotification(SignalSirname+": BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
         }
    
    u//---
      }
    //+------------------------------------------------------------------+
    //| 卖出信号函数                                             |
    //+------------------------------------------------------------------+
    void SellSignal(string SignalSirname,      // 邮件和推送消息中的指标名称
                    double &SellArrow[],       // 卖出信号的指标缓存
                    const int Rates_total,     // 当前柱子数量
                    const int Prev_calculated, // 上一根柱子的数量
                    const double &Close[],     // 收盘价
                    const int &Spread[])       // 点差
      {
    u//---
       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("SELL signal 
     Ask=",Ask,"
     Bid=",Bid,"
     currtime=",text,"
     Symbol=",Symbol()," Period=",sPeriod);
          if(EMailON) SendMail(SignalSirname+": SELL signal alert","SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
          if(PushON) SendNotification(SignalSirname+": SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
         }
    u//---
      }
    //+------------------------------------------------------------------+
    //| 获取时间框为字符串                               |
    //+------------------------------------------------------------------+
    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. Fisher_org_v1_Sign 指标在图表上的表现

图1. Fisher_org_v1_Sign 指标在图表上的表现

图2. Fisher_org_v1_Sign 指标生成提醒

图2. Fisher_org_v1_Sign 指标生成提醒

相关帖子

评论 (0)