M[i]和W[i]为什么都得0,而不是最大值和最小值呢?

 
  1. //+------------------------------------------------------------------+

  2. //| MW.mq4 |

  3. //| Copyright ?2008, MetaQuotes Software Corp. |

  4. //| [url]http://www.metaquotes.net[/url] |

  5. //+------------------------------------------------------------------+

  6. #property copyright "Copyright ?2008, MetaQuotes Software Corp."

  7. #property link "http://www.metaquotes.net"



  8. #property indicator_chart_window

  9. #property indicator_buffers 2

  10. #property indicator_color1 Green

  11. #property indicator_color2 Red



  12. double W[];

  13. double M[];

  14. double BufferW[];

  15. double BufferM[];



  16. //+------------------------------------------------------------------+

  17. //| Custom indicator initialization function |

  18. //+------------------------------------------------------------------+

  19. int init()

  20. {

  21. //---- indicator buffers mapping

  22. SetIndexBuffer(0,BufferW);

  23. SetIndexBuffer(1,BufferM);

  24. //---- indicators

  25. SetIndexStyle(0,DRAW_ARROW);

  26. SetIndexStyle(1,DRAW_ARROW);

  27. SetIndexArrow(0,217);

  28. SetIndexArrow(1,218);

  29. //---- name for DataWindow and indicator subwindow label

  30. IndicatorShortName("MW");

  31. SetIndexLabel(0,"买");

  32. SetIndexLabel(1,"卖");



  33. //----

  34. return(0);

  35. }

  36. //+------------------------------------------------------------------+

  37. //| Custom indicator deinitialization function |

  38. //+------------------------------------------------------------------+

  39. int deinit()

  40. {

  41. //----



  42. //----

  43. return(0);

  44. }

  45. //+------------------------------------------------------------------+

  46. //| Custom indicator iteration function |

  47. //+------------------------------------------------------------------+

  48. int start()

  49. {

  50. int limit;

  51. int counted_bars=IndicatorCounted();

  52. //---- last counted bar will be recounted

  53. if(counted_bars>0) counted_bars--;

  54. limit=Bars-counted_bars;

  55. //---- macd counted in the 1-st buffer

  56. for(int i=0; i<limit; i++)

  57. M[i]=MathMax(Close[i],Open[i]);

  58. W[i]=MathMin(Close[i],Open[i]);

  59. Alert(GetLastError());

  60. //---- signal line counted in the 2-nd buffer

  61. for(i=0; i<limit-2; i++)

  62. {

  63. if( M[i+1]>M[i] && M[i+1]>M[i+2] )

  64. {

  65. BufferM[i]=High[i];

  66. }

  67. if( W[i+1]<W[i] && W[i+1]<W[i+2])

  68. {

  69. BufferW[i]=Low[i];

  70. }

  71. }

  72. //----

  73. return(0);

  74. }

  75. //+------------------------------------------------------------------+
原因: