诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

多货币CCI信号提示报警 Freeway_All.mq4

Freeway_All 指标提示报警货币对
“AUDUSD”,”CHFJPY”,”EURAUD”,”EURCAD”,”EURCHF”,”EURGBP”,”EURJPY”,”EURUSD”,”GBPCHF”,”GBPJPY”,”GBPUSD”,”USDCAD”,”USDCHF”,”USDJPY”的CCI信号。

图表:Freeway_All 指标

源码:

//+------------------------------------------------------------------+
//|                                                  Freeway_All.mq4 |
//|                                       Copyright  2006, Eli hayun |
//+------------------------------------------------------------------+
#property copyright "Copyright  2006, Eli hayun"
#property link      "http://www.125808047.com"

#property indicator_chart_window

extern int       CCI_Value=50;
extern bool      UseCurrentCurrency = false;

string Currencies[] = {"AUDUSD","CHFJPY","EURAUD","EURCAD","EURCHF","EURGBP",
                       "EURJPY","EURUSD","GBPCHF","GBPJPY","GBPUSD","USDCAD",
                       "USDCHF","USDJPY"};

string   Alerted[] = {"","","","","","","","","","","","","",""};
string sComment = "", sCurrComment = "";
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
   bool GoCheck;
   if (NewBar())
   {
      sComment = "";
      for (int ii=0; ii<ArraySize(Currencies); ii++)
      {
         GoCheck = !UseCurrentCurrency;
         if (UseCurrentCurrency)
            if (Symbol() == Currencies[ii])
               GoCheck = true;
               
         if (GoCheck)
         {
            CheckFreeway(Currencies[ii],ii);      
            if (sCurrComment != "")
               sComment = sCurrComment + "\n" + sComment;
         }
      }
      if (sComment != "")
         Comment(sComment);
   }
   return(rates_total);
  }
//+------------------------------------------------------------------+
bool NewBar()
{
   static datetime dt = 0;
   if (iTime(NULL, PERIOD_M15, 0) != dt)
   {
      dt = iTime(NULL, PERIOD_M15, 0);
      return(true);
   }
   return(false);
}

void CheckFreeway(string Curr, int idx)
{
   int cci[4];
   int tf[4] = {PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4};
   string  tfName[4] = {"M15", "M30", "H1", "H4"};
   string sDir = "";
   
   sCurrComment = Curr + ": ";
   
   for (int ii=0; ii<4; ii++)
   {
      double c = iCCI(Curr, tf[ii], CCI_Value, PRICE_TYPICAL, 0);
      sCurrComment = sCurrComment + " " + tfName[ii] + ": " + DoubleToStr(c,4);
      cci[ii] = -1;
      if (c > 0) cci[ii] = 1;
      if (c < 0) cci[ii] = 0;
   }
   if (cci[0] + cci[1] + cci[2] + cci[3] == 4)
      sDir = "Up";
   if (cci[0] + cci[1] + cci[2] + cci[3] == 0)
      sDir = "Down";
      
   if (sDir != "" && (Alerted[idx] != sDir))
   {
      Alert("Freeway: ", Curr, " road clear to go ", sDir);
      PlaySound("alert1.wav");
      Alerted[idx] = sDir;
   } else {
      sCurrComment = "";
   }
}
打赏
版权所有转载请注明标题及链接:峰汇在线 » 多货币CCI信号提示报警 Freeway_All.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏