Download MetaTrader 5

Help Newbie question

To add comments, please log in or register
mankin2006
20
mankin2006 2013.12.16 11:37 
int start()
  {
  int i, 
  n, 
  Counted_Bars;
  double Sum, 
  NatLog, 
  Sum_Sq, 
  Avg, 
  Avg_Sq, 
  Rms,
  R_0,
  R_1,
  E_0,
  E_1;
  
  //------------------------------------------------------------------
  Counted_Bars= IndicatorCounted();
  i=Bars-Counted_Bars-1;
  if (i>History-1)
  i=History-1;
  while(i>=0)
   {
    Sum =0;
    Sum_Sq =0;
    for(n=i;n<=i+Aver_Bars-1;n++)
    {
      NatLog=MathLog(Close[n]);
      Sum=Sum + NatLog;
      Sum_Sq=Sum_Sq + MathPow(NatLog,2);
      
      Avg =Sum/Aver_Bars;
      Avg_Sq =Sum_Sq/Aver_Bars;
      Rms =MathSqrt(Avg_Sq);
      R_0 =Avg/Rms;
      R_1 =1/(MathSqrt(Aver_Bars));
      E_0 =(R_0-R_1)+1;
      E_1 = E_0/2;
      
    }  
      
     Buf_0[i] =E_1; //79th line 
     
     i--;
    }
     
'[' - assignment expected C:\Users\Mankin\Desktop\MetaTrader\experts\indicators\Prob_v1.mq4 (79, 11)
']' - assignment expected C:\Users\Mankin\Desktop\MetaTrader\experts\indicators\Prob_v1.mq4 (79, 13)
'=' - unexpected token C:\Users\Mankin\Desktop\MetaTrader\experts\indicators\Prob_v1.mq4 (79, 15)
';' - assignment expected C:\Users\Mankin\Desktop\MetaTrader\experts\indicators\Prob_v1.mq4 (79, 19)
Can't seem to figure out what's wrong.
Simon Gniadkowski
Moderator
18002
Simon Gniadkowski 2013.12.16 11:56  
Abcogito:
'[' - assignment expected C:\Users\Mankin\Desktop\MetaTrader\experts\indicators\Prob_v1.mq4 (79, 11)
']' - assignment expected C:\Users\Mankin\Desktop\MetaTrader\experts\indicators\Prob_v1.mq4 (79, 13)
'=' - unexpected token C:\Users\Mankin\Desktop\MetaTrader\experts\indicators\Prob_v1.mq4 (79, 15)
';' - assignment expected C:\Users\Mankin\Desktop\MetaTrader\experts\indicators\Prob_v1.mq4 (79, 19)
Can't seem to figure out what's wrong.
Neither can we without seeing all the code . . . how have you declared the buffer Buf_0 ?
mankin2006
20
mankin2006 2013.12.16 11:59  
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue

extern int History =50;  
extern int Aver_Bars =5;

double Buf_0;
//+------------------------------------------------------------------+
//| Initialization function                              |
//+------------------------------------------------------------------+

int init()
  {
   SetIndexBuffer(0,Buf_0);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   return;
  }
//+------------------------------------------------------------------+
//| Deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {

   return;
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  int i, 
  n, 
  Counted_Bars;
  double Sum, 
  NatLog, 
  Sum_Sq, 
  Avg, 
  Avg_Sq, 
  Rms,
  R_0,
  R_1,
  E_0,
  E_1;
  
  //------------------------------------------------------------------
  Counted_Bars= IndicatorCounted();
  i=Bars-Counted_Bars-1;
  if (i>History-1)
  i=History-1;
  while(i>=0)
   {
    Sum =0;
    Sum_Sq =0;
    for(n=i;n<=i+Aver_Bars-1;n++)
    {
      NatLog=MathLog(Close[n]);
      Sum=Sum + NatLog;
      Sum_Sq=Sum_Sq + MathPow(NatLog,2);
      
      Avg =Sum/Aver_Bars;
      Avg_Sq =Sum_Sq/Aver_Bars;
      Rms =MathSqrt(Avg_Sq);
      R_0 =Avg/Rms;
      R_1 =1/(MathSqrt(Aver_Bars));
      E_0 =(R_0-R_1)+1;
      E_1 = E_0/2;
      
    }  
      
     Buf_0[i] =E_1;
     
     i--;
    }
     
     
    
    
  
 
  

   return;
  }
//+------------------------------------------------------------------+
Here this might clarify some things, thanks for the response
Simon Gniadkowski
Moderator
18002
Simon Gniadkowski 2013.12.16 12:03  
Abcogito:
Here this might clarify some things, thanks for the response

OK, this isn't a buffer, it's just a double variable . . .

double Buf_0;

. . . read here and look at the sample code: IndicatorBuffers()

To add comments, please log in or register