1. #define  SH_BUY   1
  2. #define  SH_SELL  -1


  3. extern int     Otstup=30;
  4. extern double  Per=9;
  5. int            SH,NB,i,UD;
  6. double         R,SHMax,SHMin;
  7. double         BufD[];
  8. double         BufU[];


  9. int init()
  10. {
  11.    if (Bars<AllBars+Per || AllBars==0) NB=Bars-Per; else NB=AllBars;
  12.    IndicatorBuffers(2);
  13.    IndicatorShortName("SHI_SilverTrendSig");
  14.    SetIndexStyle(0,DRAW_ARROW,0,1);
  15.    SetIndexStyle(1,DRAW_ARROW,0,1);
  16.    SetIndexArrow(0,159);
  17.    SetIndexArrow(1,159);
  18.    SetIndexBuffer(0,BufU);
  19.    SetIndexBuffer(1,BufD);
  20.    SetIndexDrawBegin(0,Bars-NB);
  21.    SetIndexDrawBegin(1,Bars-NB);
  22.    Print("NB:", NB);
  23.    return(0);
  24. }


  25. int start()
  26. {
  27.    int CB=IndicatorCounted();
  28.    
  29.    if(CB<0) return(-1); else if(NB>Bars-CB) NB=Bars-CB;
  30.       for (SH=1;SH<NB;SH++)
  31.    {
  32.       for (R=0,i=SH;i<SH+10;i++) {R+=(10+SH-i)*(High[i]-Low[i]);}      R/=55;

  33.       SHMax = High[Highest(NULL,0,MODE_HIGH,Per,SH)];
  34.       SHMin = Low[Lowest(NULL,0,MODE_LOW,Per,SH)];
  35.       if (Close[SH]<SHMin+(SHMax-SHMin)*Otstup/100 && UD!=SH_SELL) { BufU[SH]=Low[SH]-R*0.5; UD=SH_SELL; }
  36.       if (Close[SH]>SHMax-(SHMax-SHMin)*Otstup/100 && UD!=SH_BUY) { BufD[SH]=High[SH]+R*0.5; UD=SH_BUY; }
  37.    }
  38.    return(0);
  39. }
复制代码
没办法循环
是不是哪里弄错了?