![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
Why ? Can you provide an example where it would be useful to modify the magic number ?
Idea 1: check the slippage for order to be closed
store the difference in points between the current price (bid/ask) and the order open price in magic number,
then close it, compair | order open price - order close price | vs magic number.
You can test how often does the broker violate the slippage assigned --> help to choose the honest broker.
idea 2: flexible take profit/ sstop loss
- ordertakeprofit() : fixed take profit
If you expect profit >= x points && signal of take profit, then take profit, you can not use ordertakeprofit().
The solution is you assign magic = x, then if profit in points > magic && signal of take profit, then close the order.
(Notes: x is not a constant, it is a variable determined by market/trading situation)
Many more applications of magic number expected, not only the role of an Id number which the order ticket already held
Idea 1: check the slippage for order to be closed
store the difference in points between the current price (bid/ask) and the order open price in magic number,
then close it, compair | order open price - order close price | vs magic number.
You can test how often does the broker violate the slippage assigned --> help to choose the honest broker.
idea 2: flexible take profit/ sstop loss
- ordertakeprofit() : fixed take profit
If you expect profit >= x points && signal of take profit, then take profit, you can not use ordertakeprofit().
The solution is you assign magic = x, then if profit in points > magic && signal of take profit, then close the order.
(Notes: x is not a constant, it is a variable determined by market/trading situation)
Many more applications of magic number expected, not only the role of an Id number which the order ticket already held
Idea 1. record the Order ticket number, the requested opening price, the actual opening price in a CSV file with the Broker name. Open the file in Excel, perform your analysis.
Idea 2. use a dummy takeprofit to save the actual takeprofit points, if current price is in the region of 1.5545 you can set a TP of 3.0000 + profit in points, then when the TP signal arrives check if current profit is > TP - 3.0000
There is no need to use the Magic Number for either of these scenarios . . . use the Magic Number for what it was designed for.
Different orders can get different magic numbers, so it is meaningless to prevent an order from changing its magic number. Also by this reason, it is ridiculous to consider magic number as the ID of the program ( a program can have many ids ? :-) ). Even if all orders must be assigned the same magic number, then it is ridiculous to consider this number as order 's ID ( many orders have the same ID ? :-) ).
dear excellent but conservative experts, please think as simply as possible
Different orders can get different magic numbers, so it is meaningless to prevent an order from changing its magic number. Also by this reason, it is ridiculous to consider magic number as the ID of the program ( a program can have many ids ? :-) ). Even if all orders must be assigned the same magic number, then it is ridiculous to consider this number as order 's ID ( many orders have the same ID ? :-) ).
dear excellent but conservative experts, please think as simply as possible
MagicNumber has never be considered as order's ID. If you wish to consider it as this, no problem. But don't ask all others programmers to do the self. What you want really is a field directly included in order's data to manage your trades. mql5 (and mql4) aren't designed this way, you can argue again and again but the best to think as simple as possible is to work the same way the language is designed. You need read/write field, use an array. Even better, use OOP, extend the classes COrderInfo (CPosition, CTrade...) with the needed field(s).
Indeed magic number is not an "orders ID" but is more of an identifier of a group of trades and not just one trade. But i do believe there is also some sense in making it editable.
So do I
Admin
15903
This issue has already been discussed many times.
The fact that is totally unacceptable to change something in perfect / completed transactions. Even when it comes to comments, or Magic ID, which are important for safety control.
In fact the principle of security of trading platforms can not even have a potential that the client can modify the least bit of information from the executed transactions.
...From here.