10评论

2收藏

双线双色MACD指标

avatar 老王吧 | 4141 人阅读 | 10 人评论 | 2017-12-27

EURGBPM30.png

  1. //+------------------------------------------------------------------+
  2. //|                                               MACD_color_new.mq4 |
  3. //|                       Copyright @2004, 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 6
  9. #property  indicator_color1  Red
  10. #property  indicator_color2  LimeGreen
  11. #property  indicator_color3  Red
  12. #property  indicator_color4  LimeGreen
  13. #property  indicator_color5  Blue
  14. #property  indicator_color6  Yellow
  15. #property  indicator_level1  0

  16. extern int FastEMA=12;
  17. extern int SlowEMA=26;
  18. extern int SignalSMA=9;

  19. double     ind_buffer1[];
  20. double     ind_buffer2[];
  21. double     ind_buffer1b[];
  22. double     ind_buffer2b[];
  23. double     ind_buffer3[];
  24. double     ind_buffer4[];
  25. double     b[999999];
  26. int init() {
  27.    SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,indicator_color1);
  28.    SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,indicator_color2);
  29.    SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,2,indicator_color3);
  30.    SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,2,indicator_color4);
  31.    SetIndexStyle(4,DRAW_LINE,EMPTY,1,indicator_color5);
  32.    SetIndexStyle(5,DRAW_LINE,EMPTY,1,indicator_color6);
  33.    SetIndexBuffer(0,ind_buffer1);
  34.    SetIndexBuffer(1,ind_buffer2);
  35.    SetIndexBuffer(2,ind_buffer1b);
  36.    SetIndexBuffer(3,ind_buffer2b);
  37.    SetIndexBuffer(4,ind_buffer3);
  38.    SetIndexBuffer(5,ind_buffer4);
  39.    IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
  40.    Comment("www.eazhijia.com");
  41.    return(0);
  42. }

  43. int start(){
  44.    int limit;
  45.    int counted_bars=IndicatorCounted();
  46.    if(counted_bars<0) return(-1);
  47.    if(counted_bars>0) counted_bars--;
  48.    limit=Bars-counted_bars;
  49.    for(int i=limit; i>=0; i--) {
  50.       b[i] = iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
  51.       ind_buffer1[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
  52.       
  53.       clearBuffers(i);
  54.       
  55.       if (b[i] < 0 ) {
  56.          if (b[i] > b[i+1]) {
  57.             ind_buffer1[i] = b[i];
  58.             ind_buffer1b[i] = 0;
  59.          } else if (b[i] < b[i+1]) {
  60.             ind_buffer1b[i] = b[i];
  61.             ind_buffer1[i] = 0;
  62.          }
  63.       } else if (b[i] > 0) {
  64.           if (b[i] < b[i+1]) {
  65.             ind_buffer2[i] = b[i];
  66.             ind_buffer2b[i] = 0;
  67.          } else if (b[i] > b[i+1]) {
  68.             ind_buffer2b[i] = b[i];
  69.             ind_buffer2[i] = 0;
  70.          }
  71.       }
  72.       ind_buffer3[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
  73.    }
  74.    for(i=0; i<limit; i++) {
  75.          ind_buffer4[i]=iMAOnArray(ind_buffer3,Bars,SignalSMA,0,MODE_SMA,i);
  76.       }
  77.    return(0);
  78. }

  79. void clearBuffers (int i) {
  80.       ind_buffer1[i] = NULL;
  81.       ind_buffer1b[i] = NULL;
  82.       ind_buffer2[i] = NULL;
  83.       ind_buffer2b[i] = NULL;
  84. }
复制代码


MACD_color_new.mq4
""
还没有人打赏,支持一下

评论|共 10 个

无念法师

发表于 2018-10-16 21:50:30 | 显示全部楼层

我非了几天才改好,没想到大神早就有了。现在弄成单线双色了

原味

发表于 2019-4-7 00:07:47 | 显示全部楼层

这个指标好用

floadyun

发表于 2019-4-28 15:38:17 | 显示全部楼层

运行报错啊,真是郁闷了

虚拟的曾经

发表于 2020-2-3 16:46:52 | 显示全部楼层

我是来刷分的,嘿嘿

sacrifice

发表于 2020-6-14 15:30:08 | 显示全部楼层

谢谢楼主,共同发展

sanlead

发表于 2020-8-9 12:51:48 | 显示全部楼层

MQ4怎么转换成EX4文件啊。。。。。。

莫安

发表于 2020-8-9 12:54:01 | 显示全部楼层

等你两世

发表于 2020-8-18 18:50:44 | 显示全部楼层

学习了,不错

rain

发表于 2021-7-20 11:38:10 | 显示全部楼层

顶下

12下一页
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则