Author: Copyright � 2011, AM2
Profit factor:
0.00
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reached
1 Views
0 Downloads
0 Favorites
Return
//+------------------------------------------------------------------+
//|                                                       Return.mq4 |
//|                                            Copyright © 2011, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, AM2"
#property link      "http://www.forexsystems.biz"

#define MAGIC  20110406

extern int StopLoss    = 300;
extern int TakeProfit  = 50;
extern int StartHour   = 21;
extern int Distance    = 50;
extern int Expiration  = 4;
extern double Lot      = 1;
                                                                                                                                
//+------------------------------------------------------------------+
int start()
  {
   int b=0,s=0,res;
   bool buy=false,sell=false; 
   double BuyPrice=Close[1]-Distance*Point;
   double SellPrice=Close[1]+Distance*Point;
   datetime expiration = TimeCurrent()+3600*Expiration;   
   for (int i=0; i<OrdersTotal(); i++)
   {  if (OrderSelect(i, SELECT_BY_POS)==true)
      {  
         if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=MAGIC) continue;
         if (OrderType()==OP_BUY) buy=true;
         if (OrderType()==OP_SELL) sell=true;
         if (OrderType()==OP_BUYLIMIT) b++;
         if (OrderType()==OP_SELLLIMIT) s++;        
      }   
   }
   if (Hour()==StartHour&&b<1)
   {               
      res=OrderSend(Symbol(),OP_BUYLIMIT,Lot,BuyPrice,3,BuyPrice-StopLoss*Point,BuyPrice+TakeProfit*Point,"",MAGIC,expiration,Blue);
   }
   
   if (Hour()==StartHour&&s<1)
   {               
      res=OrderSend(Symbol(),OP_SELLLIMIT,Lot,SellPrice,3,SellPrice+StopLoss*Point,SellPrice-TakeProfit*Point,"",MAGIC,expiration,Red );
   }   
//----   
   return(0);
  }
//+------------------------------------------------------------------+

Comments