外汇指标
高低点折线图画法学习参考
回复:0  浏览:525
  • 楼主admin 圈主
  • 2019-05-05 11:51
QQ截图20180130164632.png

  1. #property indicator_chart_window
  2. #property indicator_buffers 1
  3. #property indicator_color1 Red
  4. extern int ReversPoint=80;
  5. double RBuffer[];
  6. int Trend=1,InTrend,ttime;
  7. double Points,Last_High, Last_Low;
  8. int init()
  9.   {
  10.    string short_name;
  11.    Points=MarketInfo (Symbol(), MODE_POINT);
  12.    SetIndexStyle(0,DRAW_SECTION,EMPTY,1,Red);
  13.    SetIndexBuffer(0,RBuffer);
  14.    SetIndexEmptyValue(0,0);
  15.    short_name="RPoint";
  16.    IndicatorShortName(short_name);
  17.    SetIndexLabel(0,short_name);
  18.    SetIndexDrawBegin(0,100);
  19.    ArrayInitialize(RBuffer,0);
  20.    return(0);
  21.   }
  22. int deinit()
  23.   {
  24.    return(0);
  25.   }
  26. int start()
  27.   {
  28.    int    counted_bars=IndicatorCounted(),i,shift;
  29.    i=(Bars-counted_bars)-1;
  30.    for(shift=i; shift>=0;shift--)
  31.      {
  32.       if (Time[shift]!=ttime) InTrend=InTrend+1;
  33.       ttime=Time[shift];
  34.       RBuffer[shift]=0;
  35.       if (High[shift+1]>Last_High && Trend==1)  InTrend=1;
  36.       if (Low[shift+1]<Last_Low   && Trend==0)   InTrend=1;
  37.       if (High[shift+1]>Last_High) Last_High=High[shift+1];
  38.       if (Low[shift+1]<Last_Low)   Last_Low=Low[shift+1];
  39.       if (Trend==1 && Low[shift+1]<Last_High-ReversPoint*Points && InTrend>1)
  40.         {
  41.          Trend=0;
  42.          RBuffer[shift+InTrend]=High[shift+InTrend];
  43.          Last_High=Low[shift+1];
  44.          Last_Low=Low[shift+1];
  45.          InTrend=1;
  46.         }
  47.       if (Trend==0 && High[shift+1]>Last_Low+ReversPoint*Points && InTrend>1)
  48.         {
  49.          Trend=1;
  50.          RBuffer[shift+InTrend]=Low[shift+InTrend];
  51.          Last_Low=High[shift+1];
  52.          Last_High=High[shift+1];
  53.          InTrend=1;
  54.         }
  55.      }
  56.    return(0);
  57.   }