aizu's Knowledge Base
    • Go to: aizu.my Homepage
    • Recent
    • Tags
    • Register
    • Login

    Script : Close All

    FX
    1
    1
    222
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      aizu
      last edited by

      Create a new script file: close_all.mq4

      #property copyright "Copyright"
      #property link "..."
      
      int start(){
      
          int total = OrdersTotal();
      
          for(int i=total-1;i>=0;i--){
      
              OrderSelect(i, SELECT_BY_POS);
              int type   = OrderType();
              bool result = false;
      
              switch(type){
                  case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
                  break;
                  case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
              }
      
              if(result == false){ Sleep(0); }
      
          }
      
          return(0);
      }
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post