4评论

0收藏

HeikenAshi.mq4

avatar 老王吧 | 5293 人阅读 | 4 人评论 | 2016-04-21

EURUSDM30.png

  1. //+------------------------------------------------------------------+
  2. //|                                                  Heiken Ashi.mq4 |
  3. //|                        Copyright 2004, MetaQuotes Software Corp. |
  4. //|                                        http://www.metaquotes.net |
  5. //+------------------------------------------------------------------+
  6. //| For Heiken Ashi we recommend next chart settings ( press F8 or   |
  7. //| select on menu 'Charts'->'Properties...'):                       |
  8. //|  - On 'Color' Tab select 'Black' for 'Line Graph'                |
  9. //|  - On 'Common' Tab disable 'Chart on Foreground' checkbox and    |
  10. //|    select 'Line Chart' radiobutton                               |
  11. //+------------------------------------------------------------------+
  12. #property copyright "Copyright 2004, MetaQuotes Software Corp."
  13. #property link      "http://www.metaquotes.net"

  14. #property indicator_chart_window
  15. #property indicator_buffers 4
  16. #property indicator_color1 Red
  17. #property indicator_color2 Blue
  18. #property indicator_color3 Red
  19. #property indicator_color4 Blue
  20. //---- buffers
  21. double ExtMapBuffer1[];
  22. double ExtMapBuffer2[];
  23. double ExtMapBuffer3[];
  24. double ExtMapBuffer4[];
  25. //----
  26. int ExtCountedBars=0;
  27. //+------------------------------------------------------------------+
  28. //| Custom indicator initialization function                         |
  29. //|------------------------------------------------------------------|
  30. int init()
  31.   {
  32. //---- indicators
  33.    SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, Red);
  34.    SetIndexBuffer(0, ExtMapBuffer1);
  35.    SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, Blue);
  36.    SetIndexBuffer(1, ExtMapBuffer2);
  37.    SetIndexStyle(2,DRAW_HISTOGRAM, 0, 3, Red);
  38.    SetIndexBuffer(2, ExtMapBuffer3);
  39.    SetIndexStyle(3,DRAW_HISTOGRAM, 0, 3, Blue);
  40.    SetIndexBuffer(3, ExtMapBuffer4);
  41. //----
  42.    SetIndexDrawBegin(0,10);
  43.    SetIndexDrawBegin(1,10);
  44.    SetIndexDrawBegin(2,10);
  45.    SetIndexDrawBegin(3,10);
  46. //---- indicator buffers mapping
  47.    SetIndexBuffer(0,ExtMapBuffer1);
  48.    SetIndexBuffer(1,ExtMapBuffer2);
  49.    SetIndexBuffer(2,ExtMapBuffer3);
  50.    SetIndexBuffer(3,ExtMapBuffer4);
  51. //---- initialization done
  52.    return(0);
  53.   }
  54. //+------------------------------------------------------------------+
  55. //| Custor indicator deinitialization function                       |
  56. //+------------------------------------------------------------------+
  57. int deinit()
  58.   {
  59. //---- TODO: add your code here
  60.    
  61. //----
  62.    return(0);
  63.   }
  64. //+------------------------------------------------------------------+
  65. //| Custom indicator iteration function                              |
  66. //+------------------------------------------------------------------+
  67. int start()
  68.   {
  69.    double haOpen, haHigh, haLow, haClose;
  70.    if(Bars<=10) return(0);
  71.    ExtCountedBars=IndicatorCounted();
  72. //---- check for possible errors
  73.    if (ExtCountedBars<0) return(-1);
  74. //---- last counted bar will be recounted
  75.    if (ExtCountedBars>0) ExtCountedBars--;
  76.    int pos=Bars-ExtCountedBars-1;
  77.    while(pos>=0)
  78.      {
  79.       haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2;
  80.       haClose=(Open[pos]+High[pos]+Low[pos]+Close[pos])/4;
  81.       haHigh=MathMax(High[pos], MathMax(haOpen, haClose));
  82.       haLow=MathMin(Low[pos], MathMin(haOpen, haClose));
  83.       if (haOpen<haClose)
  84.         {
  85.          ExtMapBuffer1[pos]=haLow;
  86.          ExtMapBuffer2[pos]=haHigh;
  87.         }
  88.       else
  89.         {
  90.          ExtMapBuffer1[pos]=haHigh;
  91.          ExtMapBuffer2[pos]=haLow;
  92.         }
  93.       ExtMapBuffer3[pos]=haOpen;
  94.       ExtMapBuffer4[pos]=haClose;
  95.            pos--;
  96.      }
  97. //----
  98.    return(0);
  99.   }
  100. //+------------------------------------------------------------------+
复制代码


HeikenAshi.zip
""
还没有人打赏,支持一下

评论|共 4 个

qqyf4386

发表于 2020-6-16 20:33:26 | 显示全部楼层

谢谢楼主,共同发展

vsqga

发表于 2020-11-18 13:41:28 | 显示全部楼层

nanfeng

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

王熙凤

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

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

EA之家评论守则