MT4 iMAOnArray and iBandsOnArray effect of number of elements on calculations - page 7

 
Alexey Viktorov:

Are you saying that after if(rates_total-i >= rates_total-100);, when there are only 100 bars left to calculate, the iMAOnArray() function first recalculates the ALL array?

No, only half.
 
Alexey Viktorov:

Are you saying that after if(rates_total-i >= rates_total-100);, when there are only 100 bars left to calculate, the iMAOnArray() function first recalculates the WHOLE array?

iMAOnArray

Returnsthe valueof Moving Averagetechnical indicator calculated on data stored in the array.

doubleiMAOnArray(
doublearray[],// array
inttotal,// number of elements
intma_period,//period
intma_shift,// shift of average
intma_method,// averaging method
int shift//shift
);

Parameters

array[]

[in] Array with data.

total

[in]Number of elements to calculate. 0 means all elements of the array.

That's right, the first call to iMAOnArray with 0 in the size value unconditionally calculates the entire array, and then it seems that only the last or at most the last 2 values are calculated, although who knows, it may recalculate everything... That's why it is slowing down. That's why it doesn't matter how many bars you want to get by offset, the entire array is counted anyway.

 
Sergey Efimenko:

iMAOnArray

Returnsthe valueof Moving Averagetechnical indicator calculated on data stored in the array.

doubleiMAOnArray(
doublearray[],// array
inttotal,// number of elements
intma_period,//period
intma_shift,// shift of average
intma_method,// averaging method
int shift//shift
);

Parameters

array[]

[in] Array with data.

total

[in]Number of elements to calculate. 0 means all elements of the array.

That's right, the first call of iMAOnArray with 0 in the size value will certainly calculate the entire array, and then it seems that only the last or at most the last 2 values are calculated, although who knows, it may recalculate everything... That's why it is slowing down. That's why it doesn't matter how many bars you want to get by offset, the entire array is counted anyway.

So, I've got it wrong. And why aren't there any brakes without your complex calculations?
 
Alexey Viktorov:
Then I've got it wrong. So why is there no lag without your complicated calculations?
That's the question, why it slows down when you call it from code, but not when you simply overlay it on the chart. Well, only developers will know where to find the answer. I have a lot of complicated indicators in my charts and some of them even use recursive loops and they are supposed to "think long", while this is a simple task that takes so much time to calculate.
 
Sergey Efimenko:
That's the question, why it lags when calling it from code, but not when just overlaying on the chart. Well, only the developers know where to look for the answer. I have a lot of complicated indicators in my charts and some of them even use recursive loops and they are supposed to "think long", but this is a simple task that takes so long to be calculated.

I'm not talking about a simple chart overlay. I'm talking about that test code. It's called there, not superimposed.

Still, I think I've beaten the crap through copying part of the array. And even MODE_LWMA recalculates the same way as counting the whole array.


Red is calculated on the entire history. Green is the last 50 bars.

 
Alexey Viktorov:

...

Still, I think I've beaten the crap through copying part of the array. And even MODE_LWMA recalculates the same way as counting the whole array.

...

He's beaten it too.

 
Alexey Viktorov:

I'm not talking about a simple chart overlay. I'm talking about that test code. It's called there, not overlaid.

Still, I think I've beaten the crap through copying part of the array. And even MODE_LWMA recalculates the same way as counting the whole array.


Red counts the entire history. Green is the last 50 bars.

I get the impression you're reading my posts word for word, if not sentence for sentence. Winning what? I wrote that I got such an idea (similar code with bar calculation limitation) immediately and I tried it and got no performance boost because the array is still calculated entirely (total=0), the fact that you copy (fill in the buffer) only the last 100 elements, does not change the slowdown calculations, it brakes not getting elements in the buffer, and the calculation of the array average, which is either calculated entirely (total=0) or gives results only the first N elements (total=N), and that need the last, while the change of direction indexing does not give the desired effect.
 
Sergey Efimenko:
I get the impression that you read my posts word for word or even sentence for sentence. Winning what? I wrote that I had such an idea (similar code with bar calculation limitation) immediately, and I immediately tried it and got no performance increase, because The array is still calculated entirely (total=0), the fact that you copy (fill in the buffer) just last 100 elements doesn't take away brake from calculations, it's not getting elements into the buffer, it's the calculation of array average, which is either calculated entirely (total=0) or shows results only first N elements (total=N), and the last are needed, change of indexing direction doesn't give the desired effect.

Apparently my messages are read through too... The previous code doesn't fit, I figured out where the mistake was made. The last screenshot shows a different approach, although only last 50 bars are counted.

I didn't post the code right away expecting such reactions as "it won't work anyway" because... The code is not secret, if you want to check how it will work with your indicator, let me know.

Dmitry Fedoseev:

He won, too.

And you can only stir up a fuss. Count with how many forum members you communicate with in this tone of voice, like now with me. Go away, Satan.
 
Alexey Viktorov:

...

All you can do is make a fuss. Count up how many forum users you talk to with that tone of voice like you talk to me now. Be gone, Satan.

That's how I've been talking to people like you. There's a coalition of you here, I know.

Even yesterday you wrote here about the failure of the array copying approach. It was pointed at LWMA - it worked. You don't have enough lazy to check it with EMA, and the host of holy power? Did you put a candle in the church?

You keep whipping and whipping, and every time you keep saying, "Oops, I've got it, I made a mistake.

A fight. If you had a little sense, long ago would have seen that the issue of this topic is resolved.

You wanted to show off once again, but you got your horns blown off and immediately lamented to Satan. Man!

 
Alexey Viktorov:

Apparently my messages are read through too... The previous code doesn't fit, I figured out where the mistake was made. The last screenshot shows a different approach, although only last 50 bars are counted.

I didn't post the code right away expecting such reactions as "it won't work anyway" because... The code is not secret, if you want to check how it will work with your indicator, tell me.

Was I supposed to guess that there is a different code? Above is a screenshot too, where the last 100 bars are counted, but in fact all bars are counted, but only 100 are copied to the buffer. Yes and why not post the code at once? There wouldn't have been such an answer. I would have answered substantively, I don't understand what's the point? You can immediately see from the code what's going on, what counts and whether there are the above flaws. And what does the screen give you? Nothing but the result, and about the result already said, it can be reached in different ways, but not all of them are acceptable for the task at hand - to reduce the calculation time.