Problem....close order with specific comment.....

 

Hello,

i search any solutions for close one or more order opened manualy with my EA manager following the instruction "CLOSE ALL ORDER WITH COMMENT...".


Example:  I have a very good and profitable manual strategy with one or more position on markets...

In a manual trading is not possible specifi a ID number...now is possible to enter a comment before open the order.

For manage my multiple open position i want to take a comment "EURUSDstrategy1"...

I have other position opened in the same pair...

How to close only this opened position with this comment taken the other open???


Thanks.

 
Vedran Brkic:

Hello,

i search any solutions for close one or more order opened manualy with my EA manager following the instruction "CLOSE ALL ORDER WITH COMMENT...".


Example:  I have a very good and profitable manual strategy with one or more position on markets...

In a manual trading is not possible specifi a ID number...now is possible to enter a comment before open the order.

For manage my multiple open position i want to take a comment "EURUSDstrategy1"...

I have other position opened in the same pair...

How to close only this opened position with this comment taken the other open???


Thanks.

YOU DON'T. NEVER EVER USE THE COMMENT SECTION OF A TICKET FOR ORDER TRACKING.

The comment field on tickets is a dynamic field and is subject to modification by the broker.

Track your tickets via the Symbol and Magic number.

MT4

https://docs.mql4.com/trading/ordermagicnumber

MT5

https://www.mql5.com/en/docs/standardlibrary/expertclasses/expertbaseclasses/cexpertbase/cexpertbasemagic


There is additional information on the trade structure and such in the documentation.

OrderMagicNumber - Trade Functions - MQL4 Reference
OrderMagicNumber - Trade Functions - MQL4 Reference
  • docs.mql4.com
OrderMagicNumber - Trade Functions - MQL4 Reference
 
Jack Thomas:

YOU DON'T. NEVER EVER USE THE COMMENT SECTION OF A TICKET FOR ORDER TRACKING.

The comment field on tickets is a dynamic field and is subject to modification by the broker.

Track your tickets via the Symbol and Magic number.

MT4

https://docs.mql4.com/trading/ordermagicnumber

MT5

https://www.mql5.com/en/docs/standardlibrary/expertclasses/expertbaseclasses/cexpertbase/cexpertbasemagic


There is additional information on the trade structure and such in the documentation.


Ok but...

My order is manualy opened...OK.

My expert advisors is only for manage my opened position.

If i have more than one position opened in a same simbol with a different strategies exsample.....Strategie1 and Strategie2

If the order are placed manualy how my expert manager identify how order are to close and how NOT...in the identic simbol...???

If i place the order manualy the order not have magic number...

 
Vedran Brkic:

i search any solutions for close one or more order opened manualy with my EA manager following the instruction "CLOSE ALL ORDER WITH COMMENT...".

Example:  I have a very good and profitable manual strategy with one or more position on markets...

In a manual trading is not possible specifi a ID number...now is possible to enter a comment before open the order.

For manage my multiple open position i want to take a comment "EURUSDstrategy1"...

I have other position opened in the same pair...

How to close only this opened position with this comment taken the other open???

As @Jack Thomas has correctly stated, never use the Comment field as it can easily be changed by your broker - use the Magic Number instead.

Since, in manual trading, you can't set the Magic Number, use an EA assistant or "Order Manager" to place the orders for you with the Magic Number you wish to use. @whroeder1 has shared such a tool on the forum (I attached it too), based on an original in the CodeBase - Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 5

Then you can modify its code and add functionality to this tool to automate your closing of all trades for that specific "magic number". See the original CodeBase entry for instructions on how to use it: Money Manager Graphic Tool

Money Manager Graphic Tool
Money Manager Graphic Tool
  • votes: 39
  • 2015.09.10
  • takycard
  • www.mql5.com
Correction for more stability. Works now fine with symbols with 1 digit. Correction on the EA, better information on error, correct the open order. Added Magic Number. Added button Stop Loss On/Off. Correction on the indicator and the EA, pending order correction (don't forget to update the EA). Money Manager Graphic Tool shows Lot Size...
Files:
 
Vedran Brkic:

Ok but...

...

If i place the order manualy the order not have magic number...

It will be 0 as default
 
Vedran Brkic:

Ok but...

My order is manualy opened...OK.

My expert advisors is only for manage my opened position.

If i have more than one position opened in a same simbol with a different strategies exsample.....Strategie1 and Strategie2

If the order are placed manualy how my expert manager identify how order are to close and how NOT...in the identic simbol...???

If i place the order manualy the order not have magic number...


Create 2 scripts. One for buy and one for sell.
Script #1: BUY.mq4

This will create a buy ticket with 0.01 lots, and it will have the magic number of 123

void OnStart(){
   int ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,6,0,0,"",123,0,clrNONE);
   Alert("Ticket #"+(string)ticket+" BUY order created.");
}

Script #2: SELL.mq4

Copy the above example code, and change it to sell.

Bind the scripts to their individual hot-keys.

Set the BUY hotkey to ALT-B

Set the SELL hotkey to ALT-S

Set the Magic number in the script, and it will create tickets with the required magic number assignment.

Then you just need to set your EA to manage any ticket with the magic number of 123 or whatever.

- Jack