MACD多周期共振

楼主  收藏   举报   帖子创建时间:  2019-05-05 05:00 回复:0 关注量:634
EURGBPM30.png

  1. //+------------------------------------------------------------------+
  2. //|                                                 MACD_CJA_M1D1.mq4|
  3. //|                        Copyright @2006, metaQuotes Software Corp.|
  4. //+------------------------------------------------------------------+
  5. #property copyright "下载更多外汇EA,外汇指标,交易系统,就到【外汇EA之家】"
  6. #property link      "http://www.eazhijia.com"

  7. #property indicator_separate_window
  8. #property indicator_buffers 8
  9. #property indicator_color1 Red
  10. #property indicator_color2 Red
  11. #property indicator_color3 DeepSkyBlue
  12. #property indicator_color4 DeepSkyBlue
  13. #property indicator_color5 Orange
  14. #property indicator_color6 Maroon
  15. #property indicator_color7 Green
  16. #property indicator_color8 LawnGreen
  17. #property indicator_width1 2
  18. #property indicator_style2 2
  19. #property indicator_width3 1
  20. #property indicator_style4 2
  21. #property indicator_width5 1
  22. #property indicator_style6 0
  23. #property indicator_width7 1
  24. #property indicator_style8 0
  25. #property indicator_level1 0
  26. #property indicator_width6 2

  27. extern int       FastEMA=12;  
  28. extern int       SlowEMA=26;
  29. extern int       SignalSMA=9;

  30. extern double    MACD_FactorD1=48;
  31. extern double    MACD_FactorH4=24;
  32. extern double    MACD_FactorH1 =12;
  33. extern double    MACD_FactorM15=6;
  34. extern double    MACD_FactorM5=2;
  35. extern double    MACD_FactorM1=1;

  36. double ExtMapBuffer1[];
  37. double ExtMapBuffer2[];
  38. double ExtMapBuffer3[];
  39. double ExtMapBuffer4[];
  40. double ExtMapBuffer5[];
  41. double ExtMapBuffer6[];
  42. double ExtMapBuffer7[];
  43. double ExtMapBuffer8[];
  44. //+------------------------------------------------------------------+
  45. //| Custom indicator initialization function                         |
  46. //+------------------------------------------------------------------+
  47. int init()
  48.   {  IndicatorShortName("MACD MTF");

  49.    SetIndexStyle(0,DRAW_LINE);
  50.    SetIndexBuffer(0,ExtMapBuffer1);
  51.    SetIndexStyle(1,DRAW_LINE);
  52.    SetIndexBuffer(1,ExtMapBuffer2);
  53.    SetIndexStyle(2,DRAW_LINE);
  54.    SetIndexBuffer(2,ExtMapBuffer3);
  55.    SetIndexStyle(3,DRAW_LINE);
  56.    SetIndexBuffer(3,ExtMapBuffer4);
  57.    SetIndexStyle(4,DRAW_LINE);
  58.    SetIndexBuffer(4,ExtMapBuffer5);
  59.    SetIndexStyle(5,DRAW_LINE);
  60.    SetIndexBuffer(5,ExtMapBuffer6);
  61.    SetIndexStyle(6,DRAW_LINE);
  62.    SetIndexBuffer(6,ExtMapBuffer7);
  63.    SetIndexStyle(7,DRAW_LINE);
  64.    SetIndexBuffer(7,ExtMapBuffer8);

  65.    SetIndexLabel(0,"MACD_H4");
  66.    SetIndexLabel(1,"MACD_H4");
  67.    SetIndexLabel(2,"MACD_H1");
  68.    SetIndexLabel(3,"MACD_H1");
  69.    SetIndexLabel(4,"MACD_m15");
  70.    SetIndexLabel(5,"MACD_D1");
  71.    SetIndexLabel(6,"MACD_M5");
  72.    SetIndexLabel(7,"MACD_M1");
  73.    return(0);
  74.   }
  75. //+------------------------------------------------------------------+
  76. //| Custom indicator deinitialization function                       |
  77. //+------------------------------------------------------------------+
  78. int deinit()
  79.   {
  80.    IndicatorShortName("MACD MTF");
  81.    Comment("www.eazhijia.com");
  82.    return(0);
  83.   }
  84. //+------------------------------------------------------------------+
  85. //| Custom indicator iteration function                              |
  86. //+------------------------------------------------------------------+
  87. int start()
  88. {
  89.    int    counted_bars=IndicatorCounted();
  90.    double MyFValue=Period();
  91.    ObjectCreate("MACDMTF4", OBJ_LABEL, WindowFind("MACD MTF"), 0, 0);
  92.    ObjectSetText("MACDMTF4",DoubleToStr(MyFValue,Digits-4), 15, "Arial", DarkTurquoise);
  93.    ObjectSet("MACDMTF4", OBJPROP_CORNER, 0);
  94.    ObjectSet("MACDMTF4", OBJPROP_XDISTANCE, 430);
  95.    ObjectSet("MACDMTF4", OBJPROP_YDISTANCE, 0);
  96.    ObjectCreate("MACDMTF5", OBJ_LABEL, WindowFind("MACD MTF"), 0, 0);//1hr
  97.    ObjectSetText("MACDMTF5","Curr Period", 12, "Arial",DarkTurquoise);
  98.    ObjectSet("MACDMTF5", OBJPROP_CORNER, 0);
  99.    ObjectSet("MACDMTF5", OBJPROP_XDISTANCE, 340);
  100.    ObjectSet("MACDMTF5", OBJPROP_YDISTANCE, 0);
  101.    ObjectCreate("MACDMTF0", OBJ_LABEL, WindowFind("MACD MTF"), 0, 0);//4hr
  102.    ObjectSetText("MACDMTF0","D1", 15, "Arial",Maroon );
  103.    ObjectSet("MACDMTF0", OBJPROP_CORNER, 0);
  104.    ObjectSet("MACDMTF0", OBJPROP_XDISTANCE, 500);
  105.    ObjectSet("MACDMTF0", OBJPROP_YDISTANCE, 0);

  106.    ObjectCreate("MACDMTF", OBJ_LABEL, WindowFind("MACD MTF"), 0, 0);//1hr
  107.    ObjectSetText("MACDMTF","H4", 15, "Arial",Red );
  108.    ObjectSet("MACDMTF", OBJPROP_CORNER, 0);
  109.    ObjectSet("MACDMTF", OBJPROP_XDISTANCE, 540);
  110.    ObjectSet("MACDMTF", OBJPROP_YDISTANCE, 0);
  111.    ObjectCreate("MACDMTF1", OBJ_LABEL, WindowFind("MACD MTF"), 0, 0);//15min
  112.    ObjectSetText("MACDMTF1","H1", 15, "Arial", DodgerBlue);
  113.    ObjectSet("MACDMTF1", OBJPROP_CORNER, 0);
  114.    ObjectSet("MACDMTF1", OBJPROP_XDISTANCE, 580);
  115.    ObjectSet("MACDMTF1", OBJPROP_YDISTANCE, 0);
  116.    ObjectCreate("MACDMTF2", OBJ_LABEL, WindowFind("MACD MTF"), 0, 0);//5min
  117.    ObjectSetText("MACDMTF2","M15", 15, "Arial", Orange);
  118.    ObjectSet("MACDMTF2", OBJPROP_CORNER, 0);
  119.    ObjectSet("MACDMTF2", OBJPROP_XDISTANCE, 640);
  120.    ObjectSet("MACDMTF2", OBJPROP_YDISTANCE, 0);
  121.    ObjectCreate("MACDMTF3", OBJ_LABEL, WindowFind("MACD MTF"), 0, 0);//1min
  122.    ObjectSetText("MACDMTF3","M5", 15, "Arial",Green );
  123.    ObjectSet("MACDMTF3", OBJPROP_CORNER, 0);
  124.    ObjectSet("MACDMTF3", OBJPROP_XDISTANCE, 690);
  125.    ObjectSet("MACDMTF3", OBJPROP_YDISTANCE, 0);

  126.    ObjectCreate("MACDMTF6", OBJ_LABEL, WindowFind("MACD MTF"), 0, 0);//1min
  127.    ObjectSetText("MACDMTF6","M1", 15, "Arial",LawnGreen);
  128.    ObjectSet("MACDMTF6", OBJPROP_CORNER, 0);
  129.    ObjectSet("MACDMTF6", OBJPROP_XDISTANCE, 730);
  130.    ObjectSet("MACDMTF6", OBJPROP_YDISTANCE, 0);

  131.      for(int i=Bars;i>=0;i--)
  132.      {
  133.       ExtMapBuffer1[i]=(iMACD(NULL,PERIOD_H4,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,i)/MACD_FactorH4);
  134.       ExtMapBuffer2[i]=(iMACD(NULL,PERIOD_H4,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,i)/MACD_FactorH4);
  135.       ExtMapBuffer3[i]=(iMACD(NULL,PERIOD_H1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,i)/MACD_FactorH1);
  136.       ExtMapBuffer4[i]=(iMACD(NULL,PERIOD_H1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,i)/MACD_FactorH1);
  137.       ExtMapBuffer5[i]=(iMACD(NULL,PERIOD_M15,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,i)/MACD_FactorM15);
  138.       ExtMapBuffer6[i]=(iMACD(NULL,PERIOD_D1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,i)/MACD_FactorD1);
  139.       ExtMapBuffer7[i]=(iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,i)/MACD_FactorM5);
  140.       ExtMapBuffer8[i]=(iMACD(NULL,PERIOD_M1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,i)/MACD_FactorM1);
  141.      }
  142.     return(0);
  143.      }
  144. //+------------------------------------------------------------------+
打赏