I need help from MT4 experts

 

I want a script or EA which can close 50% of all current opened buy and sell orders 

is there anyone can help me ??

 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.

 

Help you with what? You haven't stated a problem, you stated a want.
     How To Ask Questions The Smart Way. 2004
          Prune pointless queries.

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. or pay (Freelance) someone to code it. Top of every page is the link Freelance.

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help 2017.04.21

 
ALkhalil:

I want a script or EA which can close 50% of all current opened buy and sell orders 

is there anyone can help me ??

Save it as a script or you can copy the attached file to the script. 11 2



#property strict
#property show_inputs
input  double  KapatYuzde=50;// can close x% of all current opened buy and sell orders 
int start()
{
  int total = OrdersTotal();
  for(int i=total-1;i>=0;i--)
  {
    bool sdddt=OrderSelect(i, SELECT_BY_POS);
    int type   = OrderType();

    bool result = false;
   
    double ClosedOrder=NormalizeDouble(OrderLots()*KapatYuzde/100,2);
    double EnKucukLot=MarketInfo(Symbol(),MODE_MINLOT);
    //  Print(OrderTicket()," ",ClosedOrder," LOts ",OrderLots());
      if(ClosedOrder>EnKucukLot)
       {
    switch(type)
    {
      //Close opened long positions
      
     case OP_BUY       : result = OrderClose( OrderTicket(), ClosedOrder, MarketInfo(OrderSymbol(), MODE_BID), 5, CLR_NONE );
                          break;
      
      //Close opened short positions
      case OP_SELL      : result = OrderClose( OrderTicket(), ClosedOrder, MarketInfo(OrderSymbol(), MODE_ASK), 5, CLR_NONE );
                          break;

      //Close pending orders
     // case OP_BUYLIMIT  :
     // case OP_BUYSTOP   :
     // case OP_SELLLIMIT :
     // case OP_SELLSTOP  : result = OrderDelete( OrderTicket() );
    }
    
    if(result == false)
    {
       if (GetLastError()>0) Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
      Sleep(3000);
    } 
    } 
  }
  
  return(0);
}


// Close All
int CloseAllTrades()
{
  int total = OrdersTotal();
  for(int i=total-1;i>=0;i--)
  {
    bool asdsa=OrderSelect(i, SELECT_BY_POS);
    int type   = OrderType();

    bool result = false;
     //if(OrderType()==OP_BUY) vOrderClose (OrderTicket(), lot3, MarketInfo(OrderSymbol(), MODE_BID), 10, Red);
     //if(OrderType()==OP_SELL) vOrderClose (OrderTicket(), lot3, MarketInfo(OrderSymbol(), MODE_ASK), 10, Red);
    
    switch(type)
    {
      //Close opened long positions
      case OP_BUY       : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, CLR_NONE );
                          break;
      
      //Close opened short positions
      case OP_SELL      : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, CLR_NONE );
                          break;

      //Close pending orders
      case OP_BUYLIMIT  :
      case OP_BUYSTOP   :
      case OP_SELLLIMIT :
      case OP_SELLSTOP  : result = OrderDelete( OrderTicket() );
    }
    
    if(result == false)
    {
       if (GetLastError()>0) Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
      Sleep(3000);
    }  
  }
  
  return(0);
}


Files:
 
Mehmet Bastem:

Save it as a script or you can copy the attached file to the script.



William Roeder:

Help you with what? You haven't stated a problem, you stated a want.
     How To Ask Questions The Smart Way. 2004
          Prune pointless queries.

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. or pay (Freelance) someone to code it. Top of every page is the link Freelance.

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help 2017.04.21

thank you for clarification 

 
Keith Watford:
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.

thank you


thank you

 
Mehmet Bastem:

Save it as a script or you can copy the attached file to the script.



thank you man, you are the best

Reason: