9评论

1收藏

MACD Crossover Signal

avatar 360 | 1517 人阅读 | 9 人评论 | 2018-03-08

EURGBPH1.png

  1. //+------------------------------------------------------------------+
  2. //|                                        MACD Crossover Signal.mq4 |
  3. //+------------------------------------------------------------------+

  4. #property copyright "Copyright ?2007, Robert Hill)"

  5. #property indicator_chart_window
  6. #property indicator_buffers 2
  7. #property indicator_color1 Blue
  8. #property indicator_color2 Red

  9. double CrossUp[];
  10. double CrossDown[];
  11. extern int FastEMA=12;
  12. extern int SlowEMA=26;
  13. extern int SignalSMA=9;
  14. //+------------------------------------------------------------------+
  15. //| Custom indicator initialization function                         |
  16. //+------------------------------------------------------------------+
  17. int init()
  18.   {
  19. //---- indicators
  20.    SetIndexStyle(0, DRAW_ARROW, EMPTY, 1);
  21.    SetIndexArrow(0, 221);
  22.    SetIndexBuffer(0, CrossUp);
  23.    SetIndexStyle(1, DRAW_ARROW, EMPTY, 1);
  24.    SetIndexArrow(1, 222);
  25.    SetIndexBuffer(1, CrossDown);
  26.    IndicatorDigits(2);
  27. //----
  28.    return(0);
  29.   }
  30. //+------------------------------------------------------------------+
  31. //| Custom indicator deinitialization function                       |
  32. //+------------------------------------------------------------------+
  33. int deinit()
  34.   {
  35. //----

  36. //----
  37.    return(0);
  38.   }
  39. //+------------------------------------------------------------------+
  40. //| Custom indicator iteration function                              |
  41. //+------------------------------------------------------------------+
  42. int start() {
  43.    int limit, i, counter;
  44.    double MACD_Main, MACD_Signal, MACD_MainPrevious, MACD_SignalPrevious;
  45.    double Range, AvgRange;
  46.    int counted_bars=IndicatorCounted();
  47. //---- check for possible errors
  48.    if(counted_bars<0) return(-1);
  49. //---- last counted bar will be recounted
  50.    if(counted_bars>0) counted_bars--;

  51.    limit=Bars-counted_bars;
  52.    
  53.    for(i = 0; i <= limit; i++) {
  54.    
  55.       counter=i;
  56.       Range=0;
  57.       AvgRange=0;
  58.       for (counter=i ;counter<=i+9;counter++) {
  59.          AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
  60.       }
  61.       Range=AvgRange/10;
  62.       
  63.       MACD_Main = iMACD(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_MAIN, i);
  64.       MACD_MainPrevious = iMACD(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_MAIN, i+1);
  65.       MACD_Signal = iMACD(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_SIGNAL, i);
  66.       MACD_SignalPrevious = iMACD(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_SIGNAL, i+1);

  67.       
  68.       if ((MACD_Signal < MACD_Main) && (MACD_SignalPrevious > MACD_MainPrevious)) {
  69.          CrossUp[i] = Low[i] - Range*0.5;
  70.       }
  71.       else if ((MACD_Signal > MACD_Main) && (MACD_SignalPrevious < MACD_MainPrevious)) {
  72.          CrossDown[i] = High[i] + Range*0.5;
  73.       }
  74.    }
  75.    return(0);
  76. }

复制代码


[i] MACD Crossover Signal2.mq4
""
还没有人打赏,支持一下

评论|共 9 个

zetyp

发表于 2020-6-7 21:22:31 | 显示全部楼层

小手一抖,积分到手!

素颜。

发表于 2020-6-13 15:36:38 | 显示全部楼层

没看完~~~~~~ 先顶,好同志

ssvlq

发表于 2020-7-19 12:46:17 | 显示全部楼层

帮你顶下哈!!

老★张

发表于 2020-7-30 12:50:32 | 显示全部楼层

学习了,不错

910023005

发表于 2020-8-18 22:47:46 | 显示全部楼层

帮你顶下哈!!

假如

发表于 2021-7-21 16:09:07 | 显示全部楼层

谢谢

夜宴叶问

发表于 2021-7-27 11:12:30 | 显示全部楼层

顶下

毛毛

发表于 2021-8-2 11:17:42 | 显示全部楼层

麦子

发表于 2021-8-9 10:00:21 | 显示全部楼层

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

EA之家评论守则