Reverse





//+------------------------------------------------------------------+
//|                                                      Reverse.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//|  16.12.2005  Ñêðèïò ïåðåâîðà÷èâàåò èìåþùèåñÿ ïîçèöèè.            |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"


//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
void start() {
  double Lots;
  int    op;
  for (int i=OrdersTotal()-1; i>=0; i--) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol()) {
        op=OrderType();
        if (op==OP_BUY) {
          Lots=OrderLots();
          OrderClose(OrderTicket(),OrderLots(),Bid,7,CLR_NONE);
          OrderSend(Symbol(),OP_SELL,Lots,Bid,7,0,0,"Reverse",0,0,CLR_NONE);
        }
        if (op==OP_SELL) {
          Lots=OrderLots();
          OrderClose(OrderTicket(),OrderLots(),Ask,7,CLR_NONE);
          OrderSend(Symbol(),OP_BUY,Lots,Ask,7,0,0,"Reverse",0,0,CLR_NONE);
        }
      }
    }
  }
}
//+------------------------------------------------------------------+





Sample





Analysis



Market Information Used:



Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders

It Closes Orders by itself
It automatically opens orders when conditions are reached

Other Features: