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
If I understood you correctly, you suggest simply waiting for a signal (blocking the EA thread) in the OnTick function.
This sounds like it could work, but then I could no longer relay the tick data to my DLL.
Signals can also be triggered by external factors so it's not possible to know when to stop blocking in order to get and relay the new tick data.
I am however thinking about making and loading an indicator or second EA that uses the DLL, so I essentially get two threads
(1 for feeding the tick data into the DLL and 1 for executing the trades coming from the DLL).
hacky but promising solution
One side prepares data, the other side gathers data when it requires these.
Come on Dominik, of course it's polling.
Anyway, with MT5/MQL5, you can imagine a lot of variations on polling, with a loop, events or whatever, in the end it will ALWAYS be polling because you can't call an MQL function (or trigger an event, which is the same technically) from outside.
Though if the algo allows it, you can simulate a callback with a timer (maximum delay is around 16 milliseconds).
That is not polling.
Just because you aren't blocking the thread, doesn't mean it's not polling.
Polling is just sampling the data with a time delay until something interesting happens, that's what happens here as well.
What else do you need to know? I already said the following in this thread (granted, a bit spread around multiple messages), which is all I deem interesting
- The DLL needs to be informed about every new tick price
- The DLL uses the given data as well as outside factors to decide when to open trades
- The trading signals can be initiated by the call to the DLL with tick price data (no polling or callbacks required here) BUT also by external factors independent of the terminal (would require callbacks or polling)
- I want to keep the latency to a minimum, which is why i would like to avoid polling
At the end of my last post I mentioned an idea about using 2 expert advisors at once (or alternatively single EA with an indicator)
Not sure how well i phrased that idea.
Comes down to the following:
- problem would not exist if we had two threads on the MQ5 side
- second EA = second thread
- the first EA sends all price tick updates, the second EA blocks (semaphore, mutex, channel, whatever) until it receives a trade signal from the DLL - then immediately executes it
- profit
Come on Dominik, of course it's polling.
Anyway, with MT5/MQL5, you can imagine a lot of variations on polling, with a loop, events or whatever, in the end it will ALWAYS be polling because you can't call an MQL function (or trigger an event, which is the same technically) from outside.
Though if the algo allows it, you can simulate a callback with a timer (maximum delay is around 16 milliseconds).
Just because you aren't blocking the thread, doesn't mean it's not polling.
Polling is just sampling the data with a time delay until something interesting happens, that's what happens here as well.
What else do you need to know? I already said the following in this thread (granted, a bit spread around multiple messages), which is all I deem interesting
- The DLL needs to be informed about every new tick price
- The DLL uses the given data as well as outside factors to decide when to open trades
- The trading signals can be initiated by the call to the DLL with tick price data (no polling or callbacks required here) BUT also by external factors independent of the terminal (would require callbacks or polling)
- I want to keep the latency to a minimum, which is why i would like to avoid polling
At the end of my last post I mentioned an idea about using 2 expert advisors at once (or alternatively single EA with an indicator)
Not sure how well i phrased that idea.
Comes down to the following:
- problem would not exist if we had two threads on the MQ5 side
- second EA = second thread
- the first EA sends all price tick updates, the second EA blocks (semaphore, mutex, channel, whatever) until it receives a trade signal from the DLL - then immediately executes it
- profit
EA: Oh, an Update (OnTick). Hey, let's check if DLL has new data for me. - Nope. OK.
Right here is where the polling takes place.
Reading a variable in an interval and acting upon it is polling. Only if the DLL side could "directly" inform the EA without any delays, I wouldn't consider it polling.
Now I'll return the question to you: where does the polling take place here?
From what I can see the second EAs thread will get blocked but without polling (would be waked up by some form of synchronization primitive)
I think you might be mixing up polling and blocking. ChatGPT gives a surprisingly good comparision: https://chat.openai.com/share/66952c20-2f72-45cd-ac7c-6cdd71b71b79