How to remember if the order was closed by ****

 

Is it possible to know if the order was closed by

1. normal tp/sl

2. Manual close

3. closed by **pip

4. closed by profit dollers.

etc.....

Is it possible to put mark (comments?) when CloseOrder?

If it is possible to leave a foot print, I think I can know the order was closed by 1 or 2 or 3.

Any good ideas??

 
int  OrderSend( 
   string   symbol,              // symbol 
   int      cmd,                 // operation 
   double   volume,              // volume 
   double   price,               // price 
   int      slippage,            // slippage 
   double   stoploss,            // stop loss 
   double   takeprofit,          // take profit 
   string   comment=NULL,        // comment 
   int      magic=0,             // magic number 
   datetime expiration=0,        // pending order expiration 
   color    arrow_color=clrNONE  // color 
   );

Just add a comment to your order. If you want an arrow to mark the open and close just assign a color to "arrow_color"

Also a tp or sl will appear in trade history, if you add a comment it will show up comment[tp] or comment[sl]

eg:

      int order=OrderSend(NULL, OP_BUY, LOT, Ask, 3, sl, tp, comment, magic_Num, 0, clrBlue)
 
Thank you! By the way, is it possible to leave a comment when close order? If so, I can tell order was closed which way.
 
Anthony Garot:

If you are using the CTrade library, you can hack in a little code to put a comment in there.

Of course, you will want to put this in your own library because the next time MetaTrader updates the standard library, the change will be lost.

With mql4 ?
 
Alain Verleyen:
With mql4 ?

My mistake. I open new questions from the E-mail sent to me, and I don't always check the forum section they are in.

I removed my post, which would be misleading.

I personally will be happy when MT4 goes away . . . .

 

Hello again,

Maybe you could try playing around with something like this.

//+------------------------------------------------------------------+
void IT(){ 
   double ask,bid,Spread; 
   ask=MarketInfo(Symbol(),MODE_ASK); 
   bid=MarketInfo(Symbol(),MODE_BID); 
   Spread=MarketInfo(Symbol(),MODE_SPREAD); 
   Comment(StringFormat("Show prices\nAsk = %G\nBid = %G\nSpread = %d",ask,bid,Spread)); 
  }
//+------------------------------------------------------------------+  

As you can see below OrderClose doesn't allow comment.

bool  OrderClose( 
   int        ticket,      // ticket 
   double     lots,        // volume 
   double     price,       // close price 
   int        slippage,    // slippage 
   color      arrow_color  // color 
   );
 
Thank you so much! I will try another way.
Reason: