ArraySetAsSeries really not working ...

 
Hi guys,

Here's the code i use...just a test sample:
double test_array[6] = { 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 };
   
double result1 = 0, result2 = 0;
   
ArraySetAsSeries( test_array, false ); //default behaviour
result1 = iMAOnArray( test_array, 0, 3, 0, MODE_SMA, 0 );
Print( "Default. result = " + result1 + " test_array[0]  = " + test_array[0] );
   
   
ArraySetAsSeries( test_array, true ); 
result2 = iMAOnArray( test_array, 0, 3, 0, MODE_SMA, 0 );
Print( "Modified. result = " + result2 + " test_array[0]  = " + test_array[0] );

Now this outputs:
Default. result = 0.90000000 test_array[0] = 0.50000000
Modified. result = 0.90000000 test_array[0] = 1.00000000

The result of the MA function is the same, and what i got from the documentation tell different. This is what i expect to be coming out:
Default. result = 0.60000000 test_array[0] = 0.50000000
Modified. result = 0.90000000 test_array[0] = 1.00000000

Can someone explain this to me please...or is it just a bug?

Thanks,
Alex
 
This is the same as 'Problem with iMAOnArray; It doesn't function.' right?
Looking at the silent treatment that one is getting, I would say it's a bug :)
 
Well if it's a bug then it really ruins most of MQL4's features.

The thing is, MQL4 wants to be like C but is nowhere near it.
Look at a simple issue. How do i shift arrays? How do i resize arrays efficiently?

Shifting an array of 3-4 mil records takes a hell of a long time (with a for .. . some 2-3 secs on my computer ...and it's a pretty beefy computer). And this makes me think that mql code is NOT compiled but interpreted. Also the underlaying implementation of the array may be a linked list or something.

Now if the array is a real C array underneath...i have no memcpy, and the overhead on malloc/realloc is huge on resizing arrays. But if it's a linked list...then please give us some tools to work it. And most importantly say something about it.

I searched all the docs on the Documentation pages, and not a thing is said about the language itself, efficiency, autoshifting arrays, underlaying implementation. And i believe these to be of utmost importance in an application that handles large amounts of data, and constantly needs shifting.

Now i'm criticizing and i may not be aware of all the info that's out there on the subject. And that's why i came here, hoping the dev team might sched some light on these things.
 

iMAOnArray calculates from left to right always. iMAOnArray assumes that all calculated arrays are as series, therefore index 0 in parameters is index of last array's item always.

"As series" property used for access via square brackets [...] only

 
death_ghast:
Look at a simple issue. How do i shift arrays? How do i resize arrays efficiently?
Article: Effective usage of Arrays in MQL
 
death_ghast:

The thing is, MQL4 wants to be like C but is nowhere near it.
Where is written that mql4 wants to be like C?

Since when does C have strings for example? There is not much in mql4, except maybe the ugly C-ish syntax that seems to be so popular amongst tasteless language designers nowadays, that reminds of C.

And why do you want to shift arrays at all? Why not offset the index instead, when accessing it? In C you would do pointer arithmetics to offset the whole array or similar dirty tricks, which is one of the only reasons one would ever consider the use of C for a programming task and for the very same reason [because such things are possible] it is recommended by old programming veterans like me to never ever use C for anything at all.
 
Good article, now i know why my series array was not working.
Reason: