為甚麼指標無法正常顯示,程式加上這行指令 #property strict ,就無法正常顯示

 
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 DarkGray
#property indicator_style1 2
#property indicator_color2 DarkGray
#property indicator_style2 2
#property indicator_color3 DarkGray
#property indicator_style3 2

//---- indicator parameters
input int    BandsPeriod=20;       //平均周期
input int    BandsShift=0;         //指標位移
input double BandsDeviations=2.0;  //偏差數值
//---- buffers
double MovingBuffer[];
double UpperBuffer[];
double LowerBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   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);

   return(0);
}
//+------------------------------------------------------------------+
//| Bollinger Bands                                                  |
//+------------------------------------------------------------------+
int start()
{
   int    i,k,counted_bars=IndicatorCounted();
   double deviation;
   double sum,oldval,newres;

   if(Bars<=BandsPeriod) 
      return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=BandsPeriod;i++)
      {
         MovingBuffer[Bars-i]=EMPTY_VALUE;
         UpperBuffer[Bars-i]=EMPTY_VALUE;
         LowerBuffer[Bars-i]=EMPTY_VALUE;
      }

   int limit=Bars-counted_bars;
   if(counted_bars>0) 
      limit++;
   for(i=0; i<limit; i++)
      MovingBuffer[i]=iMA(NULL,0,BandsPeriod,BandsShift,MODE_SMA,PRICE_CLOSE,i);

   i=Bars-BandsPeriod+1;
   if(counted_bars>BandsPeriod-1) 
      i=Bars-counted_bars-1;
   while(i>=0)
   {
      sum=0.0;
      k=i+BandsPeriod-1;
      oldval=MovingBuffer[i];
      while(k>=i)
      {
         newres=Close[k]-oldval;
         sum+=newres*newres;
         k--;
      }
      deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);;
      UpperBuffer[i]=oldval+deviation;
      LowerBuffer[i]=oldval-deviation;
      i--;
   }

   return(0);
}
//+------------------------------------------------------------------+
 
andy662785:
#property strict

这一行告诉编译器严格执行语法检查。

所以如果编写代码时语法不严谨,就会出许多语法错误,导致编译失败。编译失败自然就不能用了。