1赞

9评论

4收藏

3 Bar Swing

avatar 老王吧 | 4938 人阅读 | 9 人评论 | 2016-05-19

3-bar-swing-indicator.png

  1. //+------------------------------------------------------------------+
  2. //|                                                  3_bar_swing.mq4 |
  3. //|                                                         Zen_Leow |
  4. //|                                                                  |
  5. //+------------------------------------------------------------------+
  6. #property copyright "Zen_Leow"
  7. #property link      ""

  8. #property indicator_chart_window

  9. // The number of buffers for calculation, up to 8
  10. #property indicator_buffers 2

  11. // The color for displaying arrows
  12. #property indicator_color1 Green       // Long signal
  13. #property indicator_color2 Red         // Short signal

  14. // Width of the arrows
  15. #property indicator_width1 1  // Long signal arrow
  16. #property indicator_width2 1  // Short signal arrow

  17. extern int ArrowDistance = 3;

  18. // Buffers for the calculations
  19. double Up_Arrow_Buffer[];    // Long buffer for display
  20. double Down_Arrow_Buffer[];   // Short buffer for display
  21. //+------------------------------------------------------------------+
  22. //| Custom indicator initialization function                         |
  23. //+------------------------------------------------------------------+
  24. int init()
  25. {
  26.    // SetIndexStyle  - sets the new type, style, width and color for a given indicator line
  27.    // SetIndexBuffer - binds the array variable declared at a global level to the custom indicator pre-defined buffer
  28.    // SetIndexArrow  - sets an arrow symbol for indicators line of the DRAW_ARROW type.
  29.    SetIndexStyle(0, DRAW_ARROW);
  30.    SetIndexBuffer(0, Up_Arrow_Buffer);
  31.    SetIndexArrow(0, 233); // Up arrow
  32.    SetIndexStyle(1, DRAW_ARROW);
  33.    SetIndexBuffer(1, Down_Arrow_Buffer);
  34.    SetIndexArrow(1, 234); // Down arrow
  35. //----
  36.    return(0);
  37.   }
  38. //+------------------------------------------------------------------+
  39. //| Custom indicator deinitialization function                       |
  40. //+------------------------------------------------------------------+
  41. int deinit()
  42.   {
  43. //----
  44.    
  45. //----
  46.    return(0);
  47.   }
  48. //+------------------------------------------------------------------+
  49. //| Custom indicator iteration function                              |
  50. //+------------------------------------------------------------------+
  51. int start()
  52. {
  53.    int i;                           // Bar index      
  54.    int Counted_bars;                // Number of counted bars
  55.    //--------------------------------------------------------------------   
  56.    Counted_bars=IndicatorCounted(); // Number of counted bars   
  57.    i=Bars-Counted_bars-1;           // Index of the first uncounted   
  58.    if (i == 0)
  59.    {
  60.       i = 2;  // the newest signal bar is suppose to be at index 2
  61.    }
  62.    while(i>1)                      // Loop for uncounted bars     
  63.    {      
  64.       if (isUpSwingBar(i))
  65.       {
  66.          Up_Arrow_Buffer[i] = Low[i] - (ArrowDistance * Point);
  67.          Down_Arrow_Buffer[i] = EMPTY_VALUE;
  68.       }
  69.       else if (isDownSwingBar(i))
  70.       {
  71.          Down_Arrow_Buffer[i] = High[i] + (ArrowDistance * Point);
  72.          Up_Arrow_Buffer[i] = EMPTY_VALUE;
  73.       }
  74.       else
  75.       {
  76.          Up_Arrow_Buffer[i] = EMPTY_VALUE;
  77.          Down_Arrow_Buffer[i] = EMPTY_VALUE;
  78.       }
  79.       i--;
  80.    }
  81. //----
  82.    return(0);
  83. }

  84. bool isUpSwingBar(int i)
  85. {
  86.    if (Low[i] < Low[i+1] && Low[i] < Low[i-1] && High[i] < High[i+1] && High[i] < High[i-1])
  87.    {
  88.       return (true);
  89.    }
  90.    return (false);
  91. }

  92. bool isDownSwingBar(int i)
  93. {
  94.    if (Low[i] > Low[i+1] && Low[i] > Low[i-1] && High[i] > High[i+1] && High[i] > High[i-1])
  95.    {
  96.       return (true);
  97.    }
  98.    return (false);
  99. }
  100. //+------------------------------------------------------------------+
复制代码


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

评论|共 9 个

WZjh394B

发表于 2020-6-4 19:05:44 | 显示全部楼层

我是个凑数的。。。

李姐

发表于 2020-6-27 19:42:07 | 显示全部楼层

好好 学习了 确实不错

离孩农高会

发表于 2020-9-9 18:24:29 | 显示全部楼层

谢谢楼主分享

zg807

发表于 2020-11-3 09:51:31 | 显示全部楼层

谢谢楼主分享

jacky1216

发表于 2021-7-14 22:52:26 | 显示全部楼层

稳准快狠

发表于 2021-7-23 10:00:57 | 显示全部楼层

顶下

fzhogzyj

发表于 2021-7-29 13:15:05 | 显示全部楼层

谢谢

徒迁

发表于 2023-11-3 16:01:12 | 显示全部楼层

scbxiaoqiang

发表于 2024-7-27 08:34:55 | 显示全部楼层

可否加个报警

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

EA之家评论守则