What?
No. They are sequencially processed.
Believe it or not. But you could try a faulty increment code and see if it is consistent.
Take a global variable and read it, add one to the temporary variable and write it back to the global variable.
Do both in OnTick and OnEvent. Maybe use a sleep statement to increase thread race condition creation.
Let it run and see if it skips an addition.
You will see, it doesn't.
It's your code that's giving you a false interpretation.
Dominik Egert #:
What?
No. They are sequencially processed.
Believe it or not. But you could try a faulty increment code and see if it is consistent.
Take a global variable and read it, add one to the temporary variable and write it back to the global variable.
Do both in OnTick and OnEvent. Maybe use a sleep statement to increase thread race condition creation.
Let it run and see if it skips an addition.
You will see, it doesn't.
It's your code that's giving you a false interpretation.
Gosh, I found the problem. Please forget I ever wrote this thread xD

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I red somewhere an EA has a single thread running all of its code, making mutexes/semaphores not needed to handle the code inside it.
Unfortunately I have a situation which may require a mutex of some sort: I have an EA that handles both OnTick event as well as OnChartEvent, when the user sends a command to open or close a position with a market order for example. One of such commands is to invert an operation. In OnTick, there is a constant check for the state of current positions/orders in accordace to a structure. My idea is that, once a OnChartEvent was being handled, no calls to OnTick would be processed and vice-versa, but it doesn't seems to be the case: OnChartEvents are being processed at the same time as OnTick events as the log below points out:
As you can see, while a tick was being handled in OnTick, an OnChartEvent happened leading to an attempt to invert a position. After that, the current position is closed (hedge account) leading to the "profit: 0" result, but as soon as that finishes, OnTick is resumed leading to a re-update of the "profit" marker.
Judging by the scence above, it would seem I need to implement some kind of semaphore for handling OnTick and OnChartEvents, namely: don't process your code until the other is 100% finished. Am I correct regarding that? And so, how could it be implemented? In Qt's QMutex class I would just call a ::lock or even ::tryLock to handle, but I don't know how to do that in here. Notice that any tick or button press needs to be evaluated, in particularly the second.