Playsound vs Alert, play multiple sound files, and running speed question! Pls help!

 

Dear all

I would like to ask for your help on two questions:

1) this seems to be an old question but I still can't find answer from this place : how can Playsound and Alert command work simultaneously in an "indicator"? Does it can't be solved in MT4?

2) If an indicator plays multiple sound files simultaneously, some of them can't be played completely and will be interrupted in the middle. any solutions?

3) How many lines can be run within a tick by an MT4 indicator/EA? Does anybody know?

Kindly thanks to the one who would like to give me a hand!

Wing

 
3) how many lines of what? code?
 
forexCoder:
3) how many lines of what? code?


yes, lines of code.

any idea?

wing

 
As a rule, a usual program contains its code in the special function start() that is started for execution by the client terminal. In most cases function start() execution time is considerably less than the tick period. This means that most of the time the program is waiting for a tick to come. This kind of processes are characterized by the on-off ratio term. On-off ratio is the ratio of a repeating process period to the duration of the process itself. The execution time of start() Т1 is nearly from 10 to 100 milliseconds, and the Т2 time between ticks is 5 seconds at the average. Thus, the on-off ratio of a working EA is reaching Т2/Т1=1000 and more (see fig. 159). That is to say that the duration of a usual operating EA's effective capacity is 0,1% of the whole time, the rest of the time it is standing.

Sometimes complex calculations can be executed by an EA and as a result the duration of start() execution can be longer and reach tens of seconds. In these cases start() function will not be started on every tick but only on the ticks that came while the start() is waiting for them. The fig. 159 shows that the tick that came at the execution of the start() function period (at the t4 moment) will not cause a new special function's start. The next time the start() function will start at the t5 moment. The pause between the end of the current execution and the beginning of the next execution of the start() function will appear with this provision.

From the MQL4 book. I thought i remembered something like "if a calculation on single tick exceeds N seconds, the calculation is terminated and the next tick is received", but after searching for that statement now, i didn't find it so i guess i was wrong :))

So technically you can do a number of calculations per second in order of the frequency of you cpu, so in it's in the billions of calcs/sec. This is a lot of lines of code if you code stuff well or it's a line of code for any buggy infinite loop.

2) Tbh I'm unsure about this one, but there's only 1 thread in MT4 (and 5 iirc) so you're limited to a single thread of operations. This means that a wave(sound) is started, it plays and if another comes along, the first one will be interrupted and so on. You could technically overcome this by checking how long the sound is and "Sleep()"-ing the execution of EA for the duration. It would be a totally uneffective solution though and I wouldn't use it. Hopefuly soemone else will offer a better one.

Reason: