Array initalization not working correctly

 

Hey,I've been trying to create a dynamic array in which i have to store the calculation of data from the indicator and use it for different calculation but its not working. Can anyone suggest me how should initialize the array.


Code:

int exitHigh_handle;
double exitHigh_buffer[];

int exitLow_handle;
double exitLow_buffer[];

int hlv3[];
double sslExit[];
int total;
double Close_buf[]; 


int OnInit()
  {
//---
   my_symbol = Symbol();
   my_timeframe = PERIOD_CURRENT;
   
   exitHigh_handle = iCustom(NULL,0,"HMA",15,PRICE_HIGH);
   exitLow_handle = iCustom(NULL,0,"HMA",15,PRICE_LOW);
   
                 
   if(exitHigh_handle==INVALID_HANDLE)                            
   {
      Print("Failed to get the indicator handle");              
      return(-1);                                            
   }
   
   if(exitLow_handle==INVALID_HANDLE)                          
   {
      Print("Failed to get the indicator handle");             
      return(-1);                                            
   }
   
   ChartIndicatorAdd(ChartID(),0,exitHigh_handle);                 
   ArraySetAsSeries(exitHigh_buffer,true); 
   
   ChartIndicatorAdd(ChartID(),0,exitLow_handle);               
   ArraySetAsSeries(exitLow_buffer,true); 
  
   
  
   ArrayResize(hlv3,3,100);
   ArrayResize(sslExit,3,100);

//---

   ArraySetAsSeries(Close_buf,true);
   ArraySetAsSeries(hlv3,true);
   ArraySetAsSeries(sslExit,true);
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
//---
   IndicatorRelease(exitHigh_handle);
   IndicatorRelease(exitLow_handle);                             
   ArrayFree(exitHigh_buffer);
   ArrayFree(exitLow_buffer);                                     
   ArrayFree(Close_buf); 
   
  }

void OnTick()
  {
//---
   int eh=0;
   int el=0;
   int c=0;
   
   
   eh=CopyBuffer(exitHigh_handle,0,1,2,exitHigh_buffer); 
   el=CopyBuffer(exitLow_handle,0,1,2,exitLow_buffer);
   c=CopyClose(my_symbol,my_timeframe,1,2,Close_buf);
   
   if(eh<0 || el<0 || c<0)                                    //in case of errors
   {
      Print("Failed to copy data from the indicator buffer or price chart buffer");  
      return;                                                     
   }
   
   hlv3[0] = (Close_buf[0] > exitHigh_buffer[0]) ? 1 : ((Close_buf[0] < exitLow_buffer[0]) ? -1 : hlv3[1]);
   
   sslExit[0] = (hlv3[0] > -1) ? exitHigh_buffer[0] : exitLow_buffer[0];
   
   Print(exitHigh_buffer[0],", ",exitLow_buffer[0],", " ,Close_buf[0]," ,H : ", hlv3[0]," ,S : ", sslExit[0]);
  }
//+------------------------------------------------------------------+
 
   hlv3[0] = (Close_buf[0] > exitHigh_buffer[0]) ? 1 : ((Close_buf[0] < exitLow_buffer[0]) ? -1 : hlv3[1]);
You only populate index zero, why do you think index one has any value, ever?
 
William Roeder #:
You only populate index zero, why do you think index one has any value, ever?
Yes, you are right and if I initialized that value with zero then how can I auto shift that array at every new bar?
 
Fiscal_Dev # how can I auto shift that array at every new bar?

Indicators have buffers which automatically shift. Arrays do not automatically do anything. You must do it in EA.
          Array indexing and resizing an AS_SERIES array - MQL4 programming forum #2 (2017)