Metaquotes language: OrderMagicNumber() is not able to be modified - page 2

 
angevoyageur:
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 

 
sonthanhthuytu:

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. 

 
Raptor in my opinion i do think it would add flexibility and possibly save memory i.e. in your example it could help do away with recording to a file.
 

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

 
sonthanhthuytu:

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).
Documentation on MQL5: Standard Library / Trade Classes / COrderInfo
Documentation on MQL5: Standard Library / Trade Classes / COrderInfo
  • www.mql5.com
Standard Library / Trade Classes / COrderInfo - Documentation on MQL5
 
angevoyageur:
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).
Thank you very much, angryvoyageur
 
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.
 
tonny:
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
Renat 2013.08.18 3:22 p.m. | 81.4.141.1    EN

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.
 
angevoyageur:
...From here.
Now thats more understandable(but the link destination page is in arabic so i couldnt read it). But how comes tp and sl can be modified?
Reason: