3LineBreak.mq4

楼主  收藏   举报   帖子创建时间:  2019-05-05 05:01 回复:0 关注量:955
EURUSDM30.png

  1. //+------------------------------------------------------------------+
  2. //|                                                   3LineBreak.mq4 |
  3. //|                               Copyright © 2004, Poul_Trade_Forum |
  4. //|                                                         Aborigen |
  5. //|                                          http://forex.kbpauk.ru/ |
  6. //+------------------------------------------------------------------+
  7. #property copyright "Poul Trade Forum"
  8. #property link      "http://forex.kbpauk.ru/"
  9. #property indicator_chart_window
  10. #property indicator_buffers 2

  11. //---- input parameters
  12. extern int Lines_Break=3;
  13. //---- buffers
  14. double HighBuffer[];
  15. double LowBuffer[];
  16. double VALUE1,VALUE2,Swing=1,OLDSwing;
  17. //+------------------------------------------------------------------+
  18. //| Custom indicator initialization function                         |
  19. //+------------------------------------------------------------------+
  20. int init()
  21.   {
  22.    string short_name;
  23. //---- indicator line
  24.    SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2,Blue);
  25.    SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2,Red);

  26.    SetIndexBuffer(0,HighBuffer);
  27.    SetIndexBuffer(1,LowBuffer);

  28.    SetIndexEmptyValue(0,0);
  29.    SetIndexEmptyValue(1,0);

  30. //---- name for DataWindow and indicator subwindow label
  31.    short_name="3LineBreak";
  32.    IndicatorShortName(short_name);
  33.    SetIndexLabel(0,short_name);

  34. //----
  35.    SetIndexDrawBegin(0,10);
  36.    SetIndexDrawBegin(1,10);
  37. //----

  38.    return(0);
  39.   }
  40. //+------------------------------------------------------------------+
  41. //| Custor indicator deinitialization function                       |
  42. //+------------------------------------------------------------------+
  43. int deinit()
  44.   {
  45. //---- TODO: add your code here

  46. //----
  47.    return(0);
  48.   }
  49. //+------------------------------------------------------------------+
  50. //| Custom indicator iteration function                              |
  51. //+------------------------------------------------------------------+
  52. int start()
  53.   {
  54.    int    counted_bars=IndicatorCounted(),i,shift;
  55.    

  56. //---- TODO: add your code here
  57. if (counted_bars==0) counted_bars=Lines_Break+1;
  58. i=(Bars-counted_bars);

  59. for (shift=i; shift>=0;shift--)
  60. {

  61. OLDSwing=Swing;

  62. VALUE1=High[Highest(NULL,0,MODE_HIGH,Lines_Break,shift+1)];
  63. VALUE2= Low[Lowest(NULL,0,MODE_LOW,Lines_Break,shift+1)];
  64. if (OLDSwing==1 &&  Low[shift]<VALUE2) Swing=-1;
  65. if (OLDSwing==-1 && High[shift]>VALUE1 ) Swing=1;

  66. if (Swing==1)
  67. { HighBuffer[shift]=High[shift]; LowBuffer[shift]=Low[shift]; }

  68. if (Swing==-1)
  69. { LowBuffer[shift]=High[shift]; HighBuffer[shift]=Low[shift]; }


  70. //----
  71. }
  72.    return(0);
  73.   }
  74. //+------------------------------------------------------------------+
打赏