![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
@fxsaber, thank you for your advice.
Some of my strategies must act very fast on each tick to update a very tight trailing SL. My most extreme trade lately was only open during 20 seconds, did 30 SL modifications in that time and made 1740 euros profit.
I am worried that reading the trading environment on each tick is too slow. Will that not take a lot of time?
It is not too slow. You are talking microseconds. If you are using non asynchronous ordersend you are already into the milliseconds.
Edit: Convenient way to measure speed of code https://www.mql5.com/ru/code/31279I don't trust anything anymore. If the ticket is invalid, the magic number might also be invalid.
I am disappointed in the MT5 platform. I did not expect a race-condition bug in a platform that must handle millions of ticks, hunderdthousands of orders, thousands of accounts, 24/7 day and night.
For me this was a very expensive way to learn about a bug in the MT5 platform. I don't think I can ask my money back at MetaQuotes?
You are right . I just mention that because the test case picks up the different magic number , so that works for now .
But indeed the best thing to do is wait for a fix .
Usually when @fxsaber reports an error it is fixed quickly .
It is not too slow. You are talking microseconds. If you are using non asynchronous ordersend you are already into the milliseconds.
Edit: Convenient way to measure speed of code https://www.mql5.com/ru/code/31279Thank you.
I measured this on 3 different VPSes (both small and large) on a live account with multiple open orders and open positions. It takes on average 14 usec to read the environment and get all the ticket numbers. That is certainly fast enough to do every tick.
It is 14 microseconds, not milliseconds.
I know. I did say i was nitpicking.
In the spirit of Lorenzo
Not trying to nitpick but 14 is rather slow. Avoid comparing strings like _Symbol==OrderSymbol(), string comparisons are slow. With only a hand full of orders/positions you should be able to come close to zero.
Interesting. How can I filter out my orders and positions without checking the symbol? I do check the magic number first (integer comparison), but eventually need to verify the symbol, right?
--Edit-- Ok, I can swap the symbol (string comparison) and PositionType (enum comparison) checks, to postpone the string comparison until as late as possible. But I can not prevent the check, or can I?
Checking last is best if you have to. I use unique magic for each ea as wel as per symbol. I can leave out checking for it. But you can encode the symbol into the magic. You do need some kind of system for that.
But like i said. Nitpicking. How much work to shave of some microseconds.
I know. I did say i was nitpicking.
In the spirit of Lorenzo
🤣
Checking last is best if you have to. I use unique magic for each ea as wel as per symbol. I can leave out checking for it. But you can encode the symbol into the magic. You do need some kind of system for that.
But like i said. Nitpicking. How much work to shave of some microseconds.
do you produce the magic automatically oninit ?
🤣
do you produce the magic automatically oninit ?
No, i use unique magic per symbol. But William gave an example recently.
Forum on trading, automated trading systems and testing trading strategies
EA - MQL5 - managing different position opening on different TF
William Roeder, 2023.01.16 14:48
Convert the timeframe (ENUM_TIMEFRAMES) to a compact form (my TF) and add it to a base Magic number.
Why are MT5 ENUM_TIMEFRAMES strange? - General - MQL5 programming forum - Page 2 #11 (2020)