Trying to get an Array working

 

Hey, 

Ive been trying to get an array working for a while and keep coming back to it after moving on too finish other things.

Im simply wanting to store a fractal high/low value in it. I only need 3 stored so i can identify a change in trend so when the middle fractal is higher than the other two plot another buffer image

  int TotalUp =3;                      //only need three stored at a  time
     for(int j=TotalUp-1;j>=0;j--)     //cycle them working down so most recent is stored in 0
     {
      if(ExtUpFractalsBuffer[i]!=0)    //if the high fractal buffer is triggered
        {
         UP_ARRAY[j]=UP_ARRAY[j-1];    //shift the array down one 
        }
     }
        UP_ARRAY[0]=dCurrent;          //store the array with the High value
        }
        if(UP_ARRAY[0]<UP_ARRAY[1] && UP_ARRAY[1]>UP_ARRAY[2])    //if the middle fractal is higher than most recent and higher than the third one stored
        {
         TOP[i]=dCurrent;              //plot the TOP buffer on the high 
         }


The code compiles fine and is built into the mt4 fractals one which plots the fractals fine. It just won't plot the new buffer. So something must be wrong with the code.

Any help would be appreciated :)

Thank you

 
It sometimes helps to take out a line "#property strict". In the main program but also in the include files!
For some reason, with this property active, indicators will not show any graphical output.
 
Twan Jansbeken:
It sometimes helps to take out a line "#property strict". In the main program but also in the include files!
For some reason, with this property active, indicators will not show any graphical output.

Hey Twan, 

thanks for the reply removed it but no luck ha. Any other ideas ? i keep fiddling around with it perhaps its just having an off day ha.

This is the full code:

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Yellow

//---- input parameters

//---- buffers
double ExtUpFractalsBuffer[];
double ExtDownFractalsBuffer[];


double UP_ARRAY[3];
double DOWN_ARRAY[3];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping  
    SetIndexBuffer(0,ExtUpFractalsBuffer);
    SetIndexBuffer(1,ExtDownFractalsBuffer); 
    SetIndexBuffer(2,TOP);
 
//---- drawing settings
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexArrow(0,119);
    SetIndexStyle(1,DRAW_ARROW);
    SetIndexArrow(1,119);
    SetIndexStyle(2, DRAW_ARROW,0,4);
    SetIndexArrow(2,119);

//----
    SetIndexEmptyValue(0,0.0);
    SetIndexEmptyValue(1,0.0);
    SetIndexEmptyValue(2,0.0);

//---- name for DataWindow
    SetIndexLabel(0,"Fractal Up");
    SetIndexLabel(1,"Fractal Down");
    SetIndexLabel(2, "TOP");

    

//---- initialization done   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    i,nCountedBars;
   bool   bFound;
   double dCurrent;
   nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted    
   if(nCountedBars<=2)
      i=Bars-nCountedBars-3;
   if(nCountedBars>2)
     {
      nCountedBars--;
      i=Bars-nCountedBars-1;
     }      
          
//----Up and Down Fractals
   while(i>=2)
     {
      //----Fractals up
      bFound=false;
      dCurrent=Close[i];
      
        if(dCurrent>Close[i+1] && dCurrent>Close[i-1])
        {
         bFound=true;
         ExtUpFractalsBuffer[i]=dCurrent;
         
         
         int TotalUp =3;
     for(int j=TotalUp-1;j>=0;j--)
     {
      if(ExtUpFractalsBuffer[i]!=0)
        {
         UP_ARRAY[j]=dCurrent;
         UP_ARRAY[j]=UP_ARRAY[j-1]; 
        }
     }
        if(UP_ARRAY[0]<UP_ARRAY[1] && UP_ARRAY[1]>UP_ARRAY[2])
        {
         TOP[i]=dCurrent;
         }
        }
      
                                         

      //----Fractals down
      bFound=false;
      dCurrent=Close[i];
      if(dCurrent<Close[i+1] && dCurrent<Close[i-1] )
        {
        bFound=true;
        ExtDownFractalsBuffer[i]=dCurrent;
        
        }                                   
      i--;
     }
     //----------------
    
     //----------------
     return(0);
     }
     

The parts highlighted in yellow are all connected to the array and doesn't seem to be doing anything. The rest of the script works just fine plotting fractals.

Just this array part which should plot another image if out of three consecutive arrays (fractals) the middle one is the highest

???

Thanks :)

Reason: