Is there any free script to close trade with with comment

 
Hello i need any script to close trade have same comments ? as you see in the image attachment i have trades with comment H1 and others with comment H2 What i am looking for to close all trades with comment H1 only and keep trades with comment H2 open
Files:
comment.jpg  23 kb
 
if(OrderComment()=="H1")
 {
  //Do something
 }

else if(OrderComment()=="H2")
 {
  //Do something else
 }
 

Salam, Brother Abd Almouhemen ... Remember me ?

No problem, it can be done, Insha Allah ...

Give me an hour or less and I will post it here ...

 

Here we go ...

The code is not tested, but it should work ...

It closes all type of orders ... Market + Pendings.

You need to specify the comment of the orders to close once you drag the script on chart.

 Let me know if there is any trouble 1.

#property copyright "Copyright © 2015, http://oshaban.blogspot.com"
#property link      "Email: shabano@gmail.com"

#property show_inputs

input string Comment_to_close = "H1";

int start(){

   for(int i=OrdersTotal()-1;i>=0;i--){
      if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         continue;
      
      RefreshRates();
      
      if(OrderType()==OP_BUY && OrderComment()==Comment_to_close)           
         bool res1 = OrderClose(OrderTicket(),OrderLots(),Bid, 3,White);
      if(OrderType()==OP_SELL && OrderComment()==Comment_to_close)    
         bool res2 = OrderClose(OrderTicket(),OrderLots(),Ask, 3,White);
      
         
      if((OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT) && OrderComment()==Comment_to_close)
         bool res4 = OrderDelete(OrderTicket());
   }   
   return(0);
  }
 
Osama Shaban:

Here we go ...

The code is not tested, but it should work ...

It closes all type of orders ... Market + Pendings.

You need to specify the comment of the orders to close once you drag the script on chart.

 Let me know if there is any trouble 1.

Salam How are you 

Where are you Bro

can you send your contact details pleas

Reason: