Download MetaTrader 5
To add comments, please log in or register
MQL5 library has more than 1500 apps already. Contribute your own one!
risaldeb
119
risaldeb 2014.02.27 03:24 
Hi, I need help on the attached custom indicator. Every time I attach to a chart in hangs up the MetaTrader and I'm forced to close it. What is wrong with the codes??? The indicator is to determine the Maximum and Minimum price at a given number of bars.
#property indicator_separate_window    // Indicator is drawn in the main window
#property indicator_buffers 1       // Number of buffers
#property indicator_color1 Yellow     // Color of the 1st line
//#property indicator_color2 Yellow      // Color of the 2nd line
 
extern int Quant_Bars=14; 
double Buf_0[];// Buf_1[];             // Declaring indicator arrays
//THIS INDICATOR IS THE DIFFERENCE B/W MAX AND MIN PRICE IN A GIVEN TIME RANGE. USE TO DETERMINE RANGING PRICE.
//--------------------------------------------------------------------
int init()                          // Special function init()
  {
//--------------------------------------------------------------------
   SetIndexBuffer(0,Buf_0);         // Assigning an array to a buffer
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Line style
//--------------------------------------------------------------------
//   SetIndexBuffer(1,Buf_1);         // Assigning an array to a buffer
//   SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,2);// Line style
//--------------------------------------------------------------------
   return(0);                          // Exit the special funct.init()
  }
//--------------------------------------------------------------------
int start()                         // Special function start()
  {
  
  
  int    i, // Bar number
         Counted_bars;
  double minimum, maximum;    
  //--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Number of counted bars
   i=Bars-Counted_bars-1;           // Index of the first uncounted
   while(i>=0)                      // Loop for uncounted bars
      {
  
       minimum = Bid; // Minimal price 
       maximum = Bid; // Maximal price 
       for (i=0; i<=Quant_Bars-1; i++) //from zero to...
       {
       if (Low[i]<minimum)// if < known
       minimum = Low[i]; //it will be minimum
       if (High[i]> maximum)// if > known
       maximum = High[i]; //it will be maximum
       }
       
   Buf_0[i]= ((maximum-minimum)/Point);
   
   i--;   
      }                       // Calculating index of the next bar
//--------------------------------------------------------------------
   return(0);// 
  }
//--------------------------------------------------------------------
qjol
3243
qjol 2014.02.27 04:26  
Zaldy:
The indicator is to determine the Maximum and Minimum price at a given number of bars.

then use iHighest() & iLowest()

it's n endless loop

while(i>=0) // i is never gonna be 0

/
To add comments, please log in or register