2楼 
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 LightSeaGreen
#property indicator_color3 LightSeaGreen
extern int    BandsPeriod=20;
extern int    BandsShift=0;
extern double BandsDeviations=2.0;
extern int    Target=240;
double MovingBuffer;
double UpperBuffer;
double LowerBuffer;
void init()  {
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MovingBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UpperBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,LowerBuffer);
   SetIndexDrawBegin(0,BandsPeriod+BandsShift);
   SetIndexDrawBegin(1,BandsPeriod+BandsShift);
   SetIndexDrawBegin(2,BandsPeriod+BandsShift);
   if(Period()0) limit++;
   for(i=0; iBandsPeriod-1) i=Bars-counted_bars-1;
   while(i>=0)     {
      sum=0.0;
      k=i+BandsPeriod-1;
      oldval=MovingBuffer;
      while(k>=i)        {
         newres=Close[k]-oldval;
         sum+=newres*newres;
         k--;
      }
      deviation=BandsDeviations *MathSqrt(sum/BandsPeriod);
      UpperBuffer=oldval+deviation;
      LowerBuffer=oldval-deviation;
      i--;
   }
}  
韬客社区www.talkfx.co
发表于:2013-10-22 01:24只看该作者
3楼 
用得着这么麻烦吗,为什么在程序中不直接调用iBand函数呀,还要自己再算一遍。
韬客社区www.talkfx.co















