9评论

1收藏

4MAsTrend.mq4

avatar 老王吧 | 2776 人阅读 | 9 人评论 | 2016-04-25

QQ截图20160425114522.png

  1. //+------------------------------------------------------------------+
  2. //|                                                    4MAs Trend.mq4 |
  3. //|                                                      |
  4. //|                                        http://www.metaquotes.net |
  5. //+------------------------------------------------------------------+

  6. #property indicator_separate_window
  7. #property indicator_minimum 0
  8. #property indicator_maximum 1
  9. #property indicator_buffers 3
  10. #property indicator_color1 Red
  11. #property indicator_color2 LimeGreen
  12. #property indicator_color3 Gold
  13. //---- input parameters
  14. extern int Minutes=60;
  15. extern int MA1_Value=5;
  16. extern int MA1_Mode=0;
  17. extern int MA2_Value=13;
  18. extern int MA2_Mode=0;
  19. extern int MA3_Value=34;
  20. extern int MA3_Mode=3;
  21. extern int MA4_Value=55;
  22. extern int MA4_Mode=3;

  23. //---- buffers
  24. double ExtMapBuffer1[];
  25. double ExtMapBuffer2[];
  26. double ExtMapBuffer3[];
  27. string TimeFrameStr;
  28. double MA1,MA2,MA3,MA4;
  29. //+------------------------------------------------------------------+
  30. //| Custom indicator initialization function                         |
  31. //+------------------------------------------------------------------+
  32. int init()
  33.   {
  34. //---- indicators
  35.   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Red);
  36.   SetIndexBuffer(0,ExtMapBuffer1);
  37.   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2, LimeGreen);
  38.   SetIndexBuffer(1,ExtMapBuffer2);
  39.   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,2, Gold);
  40.   SetIndexBuffer(2,ExtMapBuffer3);

  41. switch(Minutes)
  42.    {
  43.       case 1 : TimeFrameStr="Period_M1"; break;
  44.       case 5 : TimeFrameStr="Period_M5"; break;
  45.       case 15 : TimeFrameStr="Period_M15"; break;
  46.       case 30 : TimeFrameStr="Period_M30"; break;
  47.       case 60 : TimeFrameStr="Period_H1"; break;
  48.       case 240 : TimeFrameStr="Period_H4"; break;
  49.       case 1440 : TimeFrameStr="Period_D1"; break;
  50.       case 10080 : TimeFrameStr="Period_W1"; break;
  51.       case 43200 : TimeFrameStr="Period_MN1"; break;
  52.       default : TimeFrameStr="Current Timeframe"; Minutes=0;
  53.    }
  54.    IndicatorShortName("Flat Trend w 4 MAs ("+TimeFrameStr+")");  


  55. //----
  56.    return(0);
  57.   }
  58. //+------------------------------------------------------------------+
  59. //| Custom indicator deinitialization function                       |
  60. //+------------------------------------------------------------------+
  61. int deinit()
  62.   {
  63. //----
  64.    
  65. //----
  66.    return(0);
  67.   }
  68. //+------------------------------------------------------------------+
  69. //| Custom indicator iteration function                              |
  70. //+------------------------------------------------------------------+
  71. int start()
  72.   {
  73.    int    counted_bars=IndicatorCounted();
  74. //----

  75. for (int i = 0; i < 300; i++){
  76.    ExtMapBuffer1[i]=0;
  77.    ExtMapBuffer2[i]=0;
  78.    ExtMapBuffer3[i]=0;
  79.    
  80.    MA1=iMA(NULL,Minutes,MA1_Value,0,MA1_Mode,PRICE_CLOSE,i);
  81.    MA2=iMA(NULL,Minutes,MA2_Value,0,MA2_Mode,PRICE_CLOSE,i);
  82.    MA3=iMA(NULL,Minutes,MA3_Value,0,MA3_Mode,PRICE_CLOSE,i);
  83.    MA4=iMA(NULL,Minutes,MA4_Value,0,MA4_Mode,PRICE_CLOSE,i);


  84.    if(MA1 > MA2 && MA2 > MA3 && MA3 > MA4 )ExtMapBuffer2[i] = 1;
  85.    if(MA1 < MA2 && MA2 < MA3 && MA3 < MA4 )ExtMapBuffer1[i] = 1;

  86.    if(ExtMapBuffer1[i] == 0 && ExtMapBuffer2[i] == 0)  {ExtMapBuffer3[i] = 1;}
  87.   
  88. }



  89.    
  90. //----
  91.    return(0);
  92.   }
  93. //+------------------------------------------------------------------+
复制代码


4MAs Trend.zip
""
还没有人打赏,支持一下

评论|共 9 个

星风雪雨

发表于 2020-6-1 11:05:23 | 显示全部楼层

我是来刷分的,嘿嘿

要一起过海洋

发表于 2020-6-6 21:28:02 | 显示全部楼层

不错不错,楼主您辛苦了。。。

正在输入

发表于 2020-7-19 11:59:43 | 显示全部楼层

谢谢楼主分享

汇市小瘪三

发表于 2020-8-31 13:03:07 | 显示全部楼层

谢谢楼主分享

苍井空

发表于 2020-9-6 10:01:01 | 显示全部楼层

帮你顶下哈!!

小妹er

发表于 2020-11-26 12:29:12 | 显示全部楼层

baoshan2007

发表于 2021-7-8 13:00:11 | 显示全部楼层

晗富敏

发表于 2021-7-8 14:37:44 | 显示全部楼层

谢谢

teststudy

发表于 2021-8-3 19:13:04 | 显示全部楼层

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

EA之家评论守则