Basic Trouble Storing Array

 
I'm making a basic indicator that shows the HOURLY and FOUR-HOURLY highs and lows.

The highs were easy. I figured out an even easier way of doing it afterwards (because by looking at it you'll know I'm an idiot) but I left it this way.

As far as the lows go, The Hourly Low will not store into the Buffer Array. It stores into a basic variable, but will not store in the Array.

Here's the complete code.

//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property indicator_color1 Red
#property indicator_color2 Orange
#property indicator_color3 Lime
#property indicator_color4 Peru
#property indicator_chart_window
#property indicator_buffers 4
 
double HourArray[];
double FourHourArray[];
double LowHourArray[];
 
extern bool HourHighLine = true;
extern bool FourHourHighLine = true;
extern bool HourLowLine = true;
extern bool FourHourLowLine = true;
 
double storehour;
double storefourhour;
double hourlow;
double fourhourlow;
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
 IndicatorBuffers(3);
 SetIndexBuffer(0,HourArray);
 SetIndexBuffer(1,FourHourArray);
 SetIndexBuffer(2,LowHourArray);
 
 SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
 SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
 SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
 
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   for (int i = 0; i <= Bars; i++) {
//     hourlow = Low[iLowest(Symbol(),PERIOD_M15,MODE_LOW,4,0)];
     for (int x = 3; x >= 0; x--) {
      if (iHigh(Symbol(),PERIOD_M15,x) > storehour) storehour = iHigh(Symbol(),PERIOD_M15,x);  
     }
     
     for (int y = 15; y >= 0; y--) {
      if (iHigh(Symbol(),PERIOD_M15,y) > storefourhour) storefourhour = iHigh(Symbol(),PERIOD_M15,y);
     }
    if (HourHighLine == true) HourArray[i] = storehour; 
    if (FourHourHighLine == true) FourHourArray[i] = storefourhour;  
    LowHourArray[i] = Low[iLowest(Symbol(),PERIOD_M15,MODE_LOW,4,0)];
   }
//----
    
//----
   return(0);
  }
//+------------------------------------------------------------------+
LowHourArray[i] is meant to store the lowest point in the last hour.

Any help will be much appreciated.
 

There are two errors, one of them trashes MT4 until it is restarted.

for ( int i = 0 ; i <= Bars ; i ++ )

Try Bars -1, you may be over running the storage size of the array you are writing to


#property indicator_color1 Red
#property indicator_color2 Orange
#property indicator_color3 Lime
#property indicator_color4 Peru
#property indicator_chart_window
#property indicator_buffers 4

int init ()
{
IndicatorBuffers ( 3 ) ;

Mismatched declarations for the number of buffers


Fix that.

Restart MT4

---

Not sureif the order of the #property settings is important, but, change it to

#property indicator_chart_window
#property indicator_buffers 3

#property indicator_color1 Red
#property indicator_color2 Orange
#property indicator_color3 Lime


 
Thanks again mate, Bars-1 fixed it