Detected Country () : English
Close - Open Orders On Current Chart - codingforex.com

Welcome to CodingForex.Com!

Knowledge portal where you can learn how to create forex indicators and robot.

Click button below to choose level that suite you:

Close - Open Orders On Current Chart

Scripts [2017-03-30 08:57:42] - by hillzx
Featured Image

void CloseThis(int Slippage) {
   bool closed = false;
   for (int i = OrdersTotal(); i >=0; i--) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      while(IsTradeContextBusy()) Sleep(100);
      RefreshRates();
      if (OrderType() == OP_BUY && Symbol() == OrderSymbol()) {
        closed = OrderClose( OrderTicket(), OrderLots(), Bid, Slippage, White);
      }
      if (OrderType() == OP_SELL && Symbol() == OrderSymbol()) {
        closed = OrderClose( OrderTicket(), OrderLots(), Ask, Slippage, White);
      }
   }
return(0);

}

void CloseThisByMagicNumber(int Slippage, int MagicNumber) {
   bool closed = false;
   for (int i = OrdersTotal(); i >=0; i--) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      while(IsTradeContextBusy()) Sleep(100);
      RefreshRates();
      if (OrderType() == OP_BUY && Symbol() == OrderSymbol() 
      && (MagicNumber == OrderMagicNumber())) {
        closed = OrderClose( OrderTicket(), OrderLots(), Bid, Slippage, White);
      }
      if (OrderType() == OP_SELL && Symbol() == OrderSymbol()
       && (MagicNumber == OrderMagicNumber())) {
        closed = OrderClose( OrderTicket(), OrderLots(), Ask, Slippage, White);
      }
   }
return(0);

}

 

Usage :

// Tutup biasa
int Slippage=3;
CloseThis(Slippage);

//Tutup menggunakan Magic Number
int Slippage=3;
int Magic=12345;
CloseThis(Slippage,Magic);


Good luck, do not forget to share and follow our official facebook and youtube, happy trading!






- Provided by HiLLzSoft Studio -