[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 407

 
Bihkul:
Colleagues, please advise what and where to change in the EA code to work in a brokerage company with five-digit quotes.
The Point variable usually helps
 
granit77:
Array.
As far as I understand, we are talking about a two-dimensional array, in order to find the value in the second dimension by the value of the first dimension. But how do you write the data into an array beforehand?
 
KONDOR:
specifically in this case you can create two arrays, a[1000] and b[1000].
And if the value you're looking for is at the very end of the array, you get a rather slow variant, because you have to look through all the values (up to break). The task is to find it quickly, spending no more time than it normally takes for a standard calculation (e.g. multiplying two variables of type double).
 
KONDOR:
There is a switch function for "fast".
Suppose that the value we are looking for is in the last line of the switch function. I don't know the methodology of switch function, but somehow it seems to me that it will be not much different from the variant with the for () loop in terms of speed.
 

It won't make a difference, of course. On the other hand, it's not always going to be the last element.

And why do you care so much about the speed? Are you going to do this calculation on every tick?

 
Mathemat:

It won't make a difference, of course. On the other hand, it's not always going to be the last element.

And why do you care so much about the speed? Are you going to do this calculation on every tick?

Yes, on every tick.
 
And don't worry, it will take a thousandth of a second to find the right value.
 
Mathemat:
And don't worry, it will take a thousandth of a second to find the right value.
There's already a pretty decent amount of calculations in there, so we wanted to optimise the speed somehow
 
There is a TimeCurrent() function that turns the current time into seconds since 1970. Is there a function that turns these seconds (int) back into datetime. Or you may need to separate seconds, minutes, hours...? Thank you.
 
If you have statistics on the frequency of different values of a[i], try putting the more frequent ones at the beginning of the array (or switch).