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

副图分形指标 Complex_pairs.mq4

Complex_pairs指标的引用说明:需要清晰可见的分形以确定信号。第二个点是体现了辅助(参考)峰值,信号线就从分形画到辅助峰。当指标线与信号线交叉时,就出现一个激进的信号。同时,如果分形位于零线以上并且交叉发生于零线以下,这就是一个买入该货币对的信号。

图表:Complex_pairs指标

源码:

//+------------------------------------------------------------------+
//|                                                Complex_pairs.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.125808047.com/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Green

double pair[];

int mn_per = 12;
int mn_fast = 3;

int w_per = 9;
int w_fast = 3;

int d_per = 5;
int d_fast = 3;

int h4_per = 12;
int h4_fast = 2;

int h1_per = 24;
int h1_fast = 8;

int m30_per = 16;
int m30_fast = 2;

int m15_per = 16;
int m15_fast = 4;

int m5_per = 12;
int m5_fast = 3;

int m1_per = 30;
int m1_fast = 10;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,pair);
   IndicatorShortName(Symbol() + "(" + Period() + "): ");
   SetIndexLabel(0, Symbol()); 
   Comment("www.125808047.com");
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
     int limit;
     int counted_bars=IndicatorCounted();
     double OPEN,HIGH,LOW,CLOSE;

     if(counted_bars<0) return(-1);

     if(counted_bars>0) counted_bars-=10;
     limit=Bars-counted_bars;

     int Price=6;
     int Mode=3;
     int per1,per2;
      switch(Period())
        {
         case 1:     per1 = m1_per; per2 = m1_fast; break;
         case 5:     per1 = m5_per; per2 = m5_fast; break;
         case 15:    per1 = m15_per;per2 = m15_fast; break;
         case 30:    per1 = m30_per;per2 = m30_fast; break;
         case 60:    per1 = h1_per; per2 = h1_fast; break;
         case 240:   per1 = h4_per; per2 = h4_fast; break;
         case 1440:  per1 = d_per;  per2 = d_fast; break;
         case 10080: per1 = w_per;  per2 = w_fast; break;
         case 43200: per1 = mn_per; per2 = mn_fast; break;
        }
     for(int i=0; i<limit; i++)
       {
         if (Symbol() == "EURUSD"){
               OPEN=EUR(Mode,PRICE_OPEN,i,per1,per2)-USD(Mode,PRICE_OPEN,i,per1,per2);
               HIGH=EUR(Mode,PRICE_HIGH,i,per1,per2)-USD(Mode,PRICE_HIGH,i,per1,per2);
               LOW=EUR(Mode,PRICE_LOW,i,per1,per2)-USD(Mode,PRICE_LOW,i,per1,per2);
               CLOSE=EUR(Mode,PRICE_CLOSE,i,per1,per2)-USD(Mode,PRICE_CLOSE,i,per1,per2);
         }
         if (Symbol() == "EURGBP"){
               OPEN=EUR(Mode,PRICE_OPEN,i,per1,per2)-GBP(Mode,PRICE_OPEN,i,per1,per2);
               HIGH=EUR(Mode,PRICE_HIGH,i,per1,per2)-GBP(Mode,PRICE_HIGH,i,per1,per2);
               LOW=EUR(Mode,PRICE_LOW,i,per1,per2)-GBP(Mode,PRICE_LOW,i,per1,per2);
               CLOSE=EUR(Mode,PRICE_CLOSE,i,per1,per2)-GBP(Mode,PRICE_CLOSE,i,per1,per2);
         }
         if (Symbol() == "EURCHF"){
               OPEN=EUR(Mode,PRICE_OPEN,i,per1,per2)-CHF(Mode,PRICE_OPEN,i,per1,per2);
               HIGH=EUR(Mode,PRICE_HIGH,i,per1,per2)-CHF(Mode,PRICE_HIGH,i,per1,per2);
               LOW=EUR(Mode,PRICE_LOW,i,per1,per2)-CHF(Mode,PRICE_LOW,i,per1,per2);
               CLOSE=EUR(Mode,PRICE_CLOSE,i,per1,per2)-CHF(Mode,PRICE_CLOSE,i,per1,per2);
         }
         if (Symbol() == "EURJPY"){
               OPEN=EUR(Mode,PRICE_OPEN,i,per1,per2)-JPY(Mode,PRICE_OPEN,i,per1,per2);
               HIGH=EUR(Mode,PRICE_HIGH,i,per1,per2)-JPY(Mode,PRICE_HIGH,i,per1,per2);
               LOW=EUR(Mode,PRICE_LOW,i,per1,per2)-JPY(Mode,PRICE_LOW,i,per1,per2);
               CLOSE=EUR(Mode,PRICE_CLOSE,i,per1,per2)-JPY(Mode,PRICE_CLOSE,i,per1,per2);
         }
         if (Symbol() == "GBPUSD"){
               OPEN=GBP(Mode,PRICE_OPEN,i,per1,per2)-USD(Mode,PRICE_OPEN,i,per1,per2);
               HIGH=GBP(Mode,PRICE_HIGH,i,per1,per2)-USD(Mode,PRICE_HIGH,i,per1,per2);
               LOW=GBP(Mode,PRICE_LOW,i,per1,per2)-USD(Mode,PRICE_LOW,i,per1,per2);
               CLOSE=GBP(Mode,PRICE_CLOSE,i,per1,per2)-USD(Mode,PRICE_CLOSE,i,per1,per2);
         }
         if (Symbol() == "GBPCHF"){
               OPEN=GBP(Mode,PRICE_OPEN,i,per1,per2)-CHF(Mode,PRICE_OPEN,i,per1,per2);
               HIGH=GBP(Mode,PRICE_HIGH,i,per1,per2)-CHF(Mode,PRICE_HIGH,i,per1,per2);
               LOW=GBP(Mode,PRICE_LOW,i,per1,per2)-CHF(Mode,PRICE_LOW,i,per1,per2);
               CLOSE=GBP(Mode,PRICE_CLOSE,i,per1,per2)-CHF(Mode,PRICE_CLOSE,i,per1,per2);
         }
         if (Symbol() == "GBPJPY"){
               OPEN=GBP(Mode,PRICE_OPEN,i,per1,per2)-JPY(Mode,PRICE_OPEN,i,per1,per2);
               HIGH=GBP(Mode,PRICE_HIGH,i,per1,per2)-JPY(Mode,PRICE_HIGH,i,per1,per2);
               LOW=GBP(Mode,PRICE_LOW,i,per1,per2)-JPY(Mode,PRICE_LOW,i,per1,per2);
               CLOSE=GBP(Mode,PRICE_CLOSE,i,per1,per2)-JPY(Mode,PRICE_CLOSE,i,per1,per2);
         }
         if (Symbol() == "USDCHF"){
               OPEN=USD(Mode,PRICE_OPEN,i,per1,per2)-CHF(Mode,PRICE_OPEN,i,per1,per2);
               HIGH=USD(Mode,PRICE_HIGH,i,per1,per2)-CHF(Mode,PRICE_HIGH,i,per1,per2);
               LOW=USD(Mode,PRICE_LOW,i,per1,per2)-CHF(Mode,PRICE_LOW,i,per1,per2);
               CLOSE=USD(Mode,PRICE_CLOSE,i,per1,per2)-CHF(Mode,PRICE_CLOSE,i,per1,per2);
         }
         if (Symbol() == "USDJPY"){
               OPEN=USD(Mode,PRICE_OPEN,i,per1,per2)-JPY(Mode,PRICE_OPEN,i,per1,per2);
               HIGH=USD(Mode,PRICE_HIGH,i,per1,per2)-JPY(Mode,PRICE_HIGH,i,per1,per2);
               LOW=USD(Mode,PRICE_LOW,i,per1,per2)-JPY(Mode,PRICE_LOW,i,per1,per2);
               CLOSE=USD(Mode,PRICE_CLOSE,i,per1,per2)-JPY(Mode,PRICE_CLOSE,i,per1,per2);
         }
         if (Symbol() == "CHFJPY"){
               OPEN=CHF(Mode,PRICE_OPEN,i,per1,per2)-JPY(Mode,PRICE_OPEN,i,per1,per2);
               HIGH=CHF(Mode,PRICE_HIGH,i,per1,per2)-JPY(Mode,PRICE_HIGH,i,per1,per2);
               LOW=CHF(Mode,PRICE_LOW,i,per1,per2)-JPY(Mode,PRICE_LOW,i,per1,per2);
               CLOSE=CHF(Mode,PRICE_CLOSE,i,per1,per2)-JPY(Mode,PRICE_CLOSE,i,per1,per2);
         }
        pair[i]=(OPEN+HIGH+LOW+CLOSE)/4;
       }
    return(rates_total);
  }
//+------------------------------------------------------------------+
double USD(int Mode, int Price, int i, int per1, int per2){
   return(
            (iMA("EURUSD",0,per1,0,Mode,Price,i)-
            iMA("EURUSD",0,per2,0,Mode,Price,i))*10000
            +
            (iMA("GBPUSD",0,per1,0,Mode,Price,i)-
            iMA("GBPUSD",0,per2,0,Mode,Price,i))*10000
            +
            (iMA("USDCHF",0,per2,0,Mode,Price,i)-
            iMA("USDCHF",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("USDJPY",0,per2,0,Mode,Price,i)-
            iMA("USDJPY",0,per1,0,Mode,Price,i))*100
          );
   
}   

double EUR(int Mode, int Price, int i, int per1, int per2){
   return(
            (iMA("EURUSD",0,per2,0,Mode,Price,i)-
            iMA("EURUSD",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("EURGBP",0,per2,0,Mode,Price,i)-
            iMA("EURGBP",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("EURCHF",0,per2,0,Mode,Price,i)-
            iMA("EURCHF",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("EURJPY",0,per2,0,Mode,Price,i)-
            iMA("EURJPY",0,per1,0,Mode,Price,i))*100
          );
   
}   

double GBP(int Mode, int Price, int i, int per1, int per2){
   return(
            (iMA("GBPUSD",0,per2,0,Mode,Price,i)-
            iMA("GBPUSD",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("EURGBP",0,per1,0,Mode,Price,i)-
            iMA("EURGBP",0,per2,0,Mode,Price,i))*10000
            +
            (iMA("GBPCHF",0,per2,0,Mode,Price,i)-
            iMA("GBPCHF",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("GBPJPY",0,per2,0,Mode,Price,i)-
            iMA("GBPJPY",0,per1,0,Mode,Price,i))*100
          );
   
}   

double CHF(int Mode, int Price, int i, int per1, int per2){
   return(
            (iMA("USDCHF",0,per1,0,Mode,Price,i)-
            iMA("USDCHF",0,per2,0,Mode,Price,i))*10000
            +
            (iMA("EURCHF",0,per1,0,Mode,Price,i)-
            iMA("EURCHF",0,per2,0,Mode,Price,i))*10000
            +
            (iMA("GBPCHF",0,per1,0,Mode,Price,i)-
            iMA("GBPCHF",0,per2,0,Mode,Price,i))*10000
            +
            (iMA("CHFJPY",0,per2,0,Mode,Price,i)-
            iMA("CHFJPY",0,per1,0,Mode,Price,i))*100
          );
   
}   

double JPY(int Mode, int Price, int i, int per1, int per2){
   return(
            (iMA("USDJPY",0,per1,0,Mode,Price,i)-
            iMA("USDJPY",0,per2,0,Mode,Price,i))*100
            +
            (iMA("EURJPY",0,per1,0,Mode,Price,i)-
            iMA("EURJPY",0,per2,0,Mode,Price,i))*100
            +
            (iMA("GBPJPY",0,per1,0,Mode,Price,i)-
            iMA("GBPJPY",0,per2,0,Mode,Price,i))*100
            +
            (iMA("CHFJPY",0,per1,0,Mode,Price,i)-
            iMA("CHFJPY",0,per2,0,Mode,Price,i))*100
          );
   
}   
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 副图分形指标 Complex_pairs.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏