Plese help, there's warning: 'piv' - expression on global scope not allowed D:\Program Files\KAB-MetaTrader 4 Client Terminal\experts\indicators\中轴线测试.mq4 (18, 18)

 
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
#property indicator_buffers 1
#property indicator_color1 DodgerBlue

double piv[];
IndicatorBuffers(1);
SetIndexBuffer(0,piv);
SetIndexStyle(0,DRAW_LINE);
int d, tt;
int init()
  {
//---- indicators
  
  return(0);
//----
  }
//-----------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i, dow, v=3600*25, count;//d指的是第几天。
   int counted_bars=IndicatorCounted();
   double PreDayClose, PreDayHigh, PreDayLow, PreDayPov;
//----
   count = iBars(NULL,tt) - iBars(NULL,tt+3600*24);
   if(counted_bars == 0)
   {
      for(d=1;v>=3600*24;d++)
      {
         tt = Time[Bars-1] + d*3600*24;
         v = Time[0] - (tt+3600*24);
         dow = TimeDayOfWeek(tt);
         if(dow>1 && dow<6)
         {
            
            PreDayClose = Close[iBars(NULL,tt)+1];
            PreDayHigh = High[iHighest(NULL,0,MODE_HIGH,count,iBars(NULL,tt-3600*24))];
            PreDayLow = Low[iLowest(NULL,0,MODE_LOW,count,iBars(NULL,tt-3600*24))];
            PreDayPov = (PreDayClose + PreDayHigh + PreDayLow)/3;
            for(i=iBars(NULL,tt);i>iBars(NULL,tt+3600*24);i--)
               piv[i] = PreDayPov;
         }
         else if(dow==1)
         {
            PreDayClose = Close[iBars(NULL,tt-2*3600)+1];
            PreDayHigh = High[iHighest(NULL,0,MODE_HIGH,count,iBars(NULL,tt-3*3600*24))];
            PreDayLow = Low[iLowest(NULL,0,MODE_LOW,count,iBars(NULL,tt-3*3600*24))];
            PreDayPov = (PreDayClose + PreDayHigh + PreDayLow)/3;
            for(i=iBars(NULL,tt);i>iBars(NULL,tt+3600*24);i--)
               piv[i] = PreDayPov;
         }
         else continue;
      }
   }
   else
   {
      if(DayOfWeek()>1 && DayOfWeek()<6)
      {
         PreDayClose = Close[iBars(NULL,tt+3600*24)+1];
         PreDayHigh = High[iHighest(NULL,0,MODE_HIGH,count,iBars(NULL,tt))];
         PreDayLow = Low[iLowest(NULL,0,MODE_LOW,count,iBars(NULL,tt))];
         PreDayPov = (PreDayClose + PreDayHigh + PreDayLow)/3;
         for(i=iBars(NULL,tt);i>=0;i--)
            piv[i] = PreDayPov;
      }
      else if(DayOfWeek()==1)
      {
          PreDayClose = Close[iBars(NULL,tt-3600*24)+1];
          PreDayHigh = High[iHighest(NULL,0,MODE_HIGH,count,iBars(NULL,tt-2*3600*24))];
          PreDayLow = Low[iLowest(NULL,0,MODE_LOW,count,iBars(NULL,tt-2*3600*24))];
          PreDayPov = (PreDayClose + PreDayHigh + PreDayLow)/3;
          for(i=iBars(NULL,tt);i>=0;i--)
             piv[i] = PreDayPov;
      }
      else return(0);
   }
//----
   return(0);
  }
'piv' - expression on global scope not allowed D:\Program Files\KAB-MetaTrader 4 Client Terminal\experts\indicators\中轴线测试.mq4 (18, 18)

I don't know why is that happen,

Could anybody help me, Thanks so much!

==============================================================

the purpose of this indicator, just to draw a povid line for every day, by the last day's data.

but when I operate it, there's no even a single line appear.

and the report is

2013.11.01 22:46:28 RF-GC,Daily: 2 parameter for SetIndexBuffer function must be array:

 
matthewpang:
'piv' - expression on global scope not allowed D:\Program Files\KAB-MetaTrader 4 Client Terminal\experts\indicators\中轴线测试.mq4 (18, 18)

I don't know why is that happen,

Could anybody help me, Thanks so much!

==============================================================

the purpose of this indicator, just to draw a povid line for every day, by the last day's data.

but when I operate it, there's no even a single line appear.

and the report is

2013.11.01 22:46:28 RF-GC,Daily: 2 parameter for SetIndexBuffer function must be array:

Doesn't this . . .

IndicatorBuffers(1);
SetIndexBuffer(0,piv);
SetIndexStyle(0,DRAW_LINE);

. . . belong in init() ?

 
RaptorUK:

Doesn't this . . .

. . . belong in init() ?


if I define the buffer in fcunction init, is that still works in function start?
 
matthewpang:

if I define the buffer in fcunction init, is that still works in function start?
I didn't say to move the buffer declaration to init() . . . did you try what I suggested ?
 
RaptorUK:
I didn't say to move the buffer declaration to init() . . . did you try what I suggested ?


Yes, it works, no more warning. But of the result, I cannot see any lines appear...

 
matthewpang: Yes, it works, no more warning. But of the result, I cannot see any lines appear...
iBars(NULL,tt+3600*24)
Because everything else you wrote is babble. What is the second parameter to iBars