Array Problem

 

Hello,

I defined 2 Arrays, 2 dimention each .

Initialized both of them (not in the init() function but at the start() function!!).

I'm checking if I need to resize them before I put values, and the resizing succeed .

The first array is working good, But on second Array, I can't put values and it is always returns value '0' eccept from position Array[0][0] .

I tryed to declare the Arrays as 'Static' but it seems nothing help .

The 2 Arrays are exactly the same, and the code is the same .... P L E A S E H E L P :)

 
show your code.
 

hi phy,

this is my code, a lot of printing and allerts in order to debug ....

thanks for looking

gal



static double UpFractalsBuffer[15][10];
static double DownFractalsBuffer[15][10];


//+------------------------------------------------------------------+
int start()
{
int i,j;
int temp_bar;
//----------------------- Array Initialization ----------------------
ArrayInitialize(UpFractalsBuffer,0);
int err=GetLastError();
Print("UpFractalsBuffer init error(",err,"): ",ErrorDescription(err));

ArrayInitialize(DownFractalsBuffer,0);
err=GetLastError();
Print("DownFractalsBuffer init error(",err,"): ",ErrorDescription(err));

//----------------------- Array Resizing ----------------------
ArrayResize(UpFractalsBuffer,20);
err=GetLastError();
Print("UpFractalsBuffer resize error(",err,"): ",ErrorDescription(err));

ArrayResize(DownFractalsBuffer,20);
err=GetLastError();
Print("DownFractalsBuffer resize error(",err,"): ",ErrorDescription(err));

int element_count=ArrayResize(DownFractalsBuffer,15);
Print("DownFractalsBuffer element_count After init",element_count);

//-------------------------------------------------------------------------------------------
// Fisrt Get all fractals from the minimal TF (external param) and save it in a Local array
//-------------------------------------------------------------------------------------------

int Tf_From_Bars_In_Chart = WindowBarsPerChart()*(Period()/Tf_From); // number of bars in min. TF
int Up_Index = 0,Down_Index = 0;

for (i=2;i<Tf_From_Bars_In_Chart;i++){
//--------------------------- Get Up Fractals ---------------------------------
double temp_up_price = iCustom(Symbol(),Tf_From,"fractal_price",false,0,i);

if (temp_up_price>0) {

if (ArrayRange( UpFractalsBuffer, 1) < Up_Index +1 ) {
element_count=ArrayResize(UpFractalsBuffer, Up_Index+1 );
if (element_count==-1) Alert("Couldn''t Resize Array UpFractalsBuffer");
else Alert("element_count Array UpFractalsBuffer",element_count);
}

UpFractalsBuffer[Up_Index,0] = temp_up_price ;
UpFractalsBuffer[Up_Index,1] = iCustom(Symbol(),Tf_From,"fractal_price",false,2,i);
Print("up_price= ",UpFractalsBuffer[Up_Index][0]," in Bar - ",DoubleToStr(UpFractalsBuffer[Up_Index][1],0));
Up_Index ++;

}
//--------------------------- Get Up Fractals ---------------------------------
double temp_down_price = iCustom(Symbol(),Tf_From,"fractal_price",false,1,i);

if (temp_down_price>0) {

if (ArrayRange( DownFractalsBuffer, 1) < Down_Index + 1 ) {
element_count=ArrayResize(DownFractalsBuffer, Down_Index+1 );
if (element_count==-1) Alert("Couldn''t Resize Array DownFractalsBuffer");
else Alert("element_count Array DownFractalsBuffer",element_count);
}
DownFractalsBuffer[Down_Index,0] = temp_down_price ;
DownFractalsBuffer[Down_Index,1] = iCustom(Symbol(),Tf_From,"fractal_price",false,3,i);
Down_Index ++;

Print("down_price= ",DownFractalsBuffer[Down_Index][0]," in Bar - ",DoubleToStr(DownFractalsBuffer[Down_Index][1],0));
}
} // End loop at bars of minimum TF

Print(" Up_Index ",Up_Index);
Print(" Down_Index ",Down_Index);

 

Can't test your code.

If you think the array doesn't work, then assign values to it for testing.

If the array accepts your test values, look elsewhere for your problem.

Perhaps the iCustom() call is not so good.

 
phy:

Can't test your code.

If you think the array doesn't work, then assign values to it for testing.

If the array accepts your test values, look elsewhere for your problem.

Perhaps the iCustom() call is not so good.

tryed that already, the array does not accept the fix values and the iCustom returns the right values ....

do u have another idea how to figure this bizare problem ...

did any one bumped into this kind of problem with Array ??

Reason: