通道 DJ

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

  1. //+------------------------------------------------------------------+
  2. //|                                                     DJ_Lines.mq4 |
  3. //|                       Copyright @2005, metaQuotes Software Corp. |
  4. //+------------------------------------------------------------------+
  5. #property copyright "下载更多外汇EA,外汇指标,交易系统,就到【外汇EA之家】"
  6. #property link      "http://www.eazhijia.com"

  7. #property indicator_chart_window
  8. #property indicator_buffers 7
  9. #property indicator_color1 White
  10. #property indicator_color2 Red
  11. #property indicator_color3 Red
  12. #property indicator_color4 Yellow
  13. #property indicator_color5 Yellow
  14. #property indicator_color6 LimeGreen
  15. #property indicator_color7 LimeGreen

  16. extern int show_comment=1;
  17. extern int how_long=1000;

  18. double E2[];
  19. double ff[];
  20. double E4[];
  21. double E5[];
  22. double E6[];
  23. double E7[];
  24. double E8[];
  25. //+------------------------------------------------------------------+
  26. //| Custom indicator initialization function |
  27. //+------------------------------------------------------------------+
  28. int onInit(void)
  29. {
  30. SetIndexBuffer(0, E2);
  31. SetIndexBuffer(1, ff);
  32. SetIndexBuffer(2, E4);
  33. SetIndexBuffer(3, E5);
  34. SetIndexBuffer(4, E6);
  35. SetIndexBuffer(5, E7);
  36. SetIndexBuffer(6, E8);

  37. SetIndexStyle(0, DRAW_LINE,1,2);
  38. SetIndexStyle(1, DRAW_LINE);
  39. SetIndexStyle(2, DRAW_LINE);
  40. SetIndexStyle(3, DRAW_LINE);
  41. SetIndexStyle(4, DRAW_LINE);
  42. SetIndexStyle(5, DRAW_LINE);
  43. SetIndexStyle(6, DRAW_LINE);
  44. Comment("www.eazhijia.com");
  45. return(INIT_SUCCEEDED);
  46. }

  47. //+------------------------------------------------------------------+
  48. //| Custom indicator iteration function                              |
  49. //+------------------------------------------------------------------+
  50. int onCalculate(const int rates_total,
  51.                 const int prev_calculated,
  52.                 const datetime &time[],
  53.                 const double &open[],
  54.                 const double &high[],
  55.                 const double &low[],
  56.                 const double &close[],
  57.                 const long &tick_volume[],
  58.                 const long &volume[],
  59.                 const int &spread[])
  60. {
  61. int cnt=0;
  62. int begin_bar=0;
  63. int prev_day, cur_day;
  64. double day_high=0;
  65. double day_low=0;
  66. double yesterday_high=0;
  67. double yesterday_low=0;
  68. double yesterday_close=0;
  69. double P, S, R, P1, P2, P3, C1, C2, C3;

  70. if (Period() >= PERIOD_D1) {
  71. Comment("WARNING: Invalid timeframe! Valid value < D1.");
  72. return(0);
  73. }

  74. if (how_long == -1) {
  75. begin_bar = Bars;
  76. } else {
  77. begin_bar = how_long;
  78. }

  79. for (cnt = begin_bar; cnt >= 0; cnt--) {
  80. cur_day = TimeDay(Time[cnt]);
  81. if (prev_day != cur_day) {
  82. yesterday_close = Close[cnt+1];
  83. yesterday_high = day_high;
  84. yesterday_low = day_low;
  85. P = (yesterday_high + yesterday_low + yesterday_close) / 3;
  86. R = yesterday_high;
  87. S = yesterday_low;
  88. P1 = 2 * P - S;
  89. C1 = 2 * P - R;
  90. P2 = P + (P1 - C1);
  91. C2 = P - (P1 - C1);
  92. P3 = R + (2 * (P - S));
  93. C3 = S - (2 * (R - P));

  94. day_high = High[cnt];
  95. day_low = Low[cnt];

  96. prev_day = cur_day;
  97. }

  98. day_high = MathMax(day_high, High[cnt]);
  99. day_low = MathMin(day_low, Low[cnt]);

  100. E2[cnt] = P;
  101. ff[cnt] = P1;
  102. E4[cnt] = C1;
  103. E5[cnt] = P2;
  104. E6[cnt] = C2;
  105. E7[cnt] = P3;
  106. E8[cnt] = C3;
  107. }

  108. if (show_comment == 1) {
  109. P = (yesterday_high + yesterday_low + yesterday_close) / 3;
  110. R = yesterday_high;
  111. S = yesterday_low;
  112. P1 = 2 * P - S;
  113. C1 = 2 * P - R;
  114. P2 = P + (P1 - C1);
  115. C2 = P - (P1 - C1);
  116. P3 = R + (2 * (P - S));
  117. C3 = S - (2 * (R - P));
  118. Comment("Current H=", R, ", L=", S, ", HL?3=", P, " C2=", C2, ", H-L=", (R-S)/Point );
  119. }
  120. return(rates_total);
  121. }
  122. //+-----------------------------------------------------------------
打赏