Please help on simple ArrayCopy

 

Hello, struggling with a simple array copy. cannot find why it is wrong...


int A[]={4,3,9,12,15};
int B[];

ArrayCopy(B,A,0,0,WHOLE_ARRAY);

Print("Size: ", ArraySize(B));

--> Returns 1 which is value 4.

Also tried:

ArrayResize(B,ArraySize(A));
ArrayCopy(B,A,0,0,WHOLE_ARRAY);


but same result
 
algotrader01:

Hello, struggling with a simple array copy. cannot find why it is wrong...


Works for me.

#property strict     // because you should

void OnStart()
{
   int A[]={4,3,9,12,15};
   int B[];
   
   int numCopied = ArrayCopy(B,A,0,0,WHOLE_ARRAY);
   
   Print(StringFormat("Size: [%d] Num Copied [%d]", ArraySize(B), numCopied));
}

Results:

2018.04.19 12:18:44.777 Quick Info EURJPY,H1: Size: [5] Num Copied [5]
 
Hey Anthony, thanks for testing. It's odd working for you. I did not use the strict part, not sure whether it is necessary. I also did not do it in the void start function but that shouldn't matter. 

I will copy paste your example tomorrow and see whether it works or not....

Thanks so far!