e-MovingInWL_v1

Author: ��� ����� �. aka KimIV
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites
e-MovingInWL_v1
//+----------------------------------------------------------------------------+
//|                                                          e-MovingInWL.mq4  |
//|                                                    Êèì Èãîðü Â. aka KimIV  |
//|                                                       http://www.kimiv.ru  |
//+----------------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"

//------- Âíåøíèå ïàðàìåòðû ----------------------------------------------------
extern int  LevelWLoss  = 1;      // Óðîâåíü áåçóáûòêà
extern int  LevelProfit = 10;     // Óðîâåíü ïðîôèòà
extern bool ShowComment = True;   // Ïîêàçûâàòü êîììåíòàðèè
extern bool SoundAlert  = True;   // Çâóê

//+----------------------------------------------------------------------------+
//|  Custor expert deinitialization function                                   |
//+----------------------------------------------------------------------------+
void deinit() { Comment(""); }
//+----------------------------------------------------------------------------+
//|  expert start function                                                     |
//+----------------------------------------------------------------------------+
void start() 
  {
   bool   fm;
   double pBid,pAsk,pp;
   int    i,nd,o=OrdersTotal();
   string comm="";

   for(i=0; i<o; i++) 
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) 
        {
         nd=MarketInfo(OrderSymbol(), MODE_DIGITS);
         pp=MarketInfo(OrderSymbol(), MODE_POINT);
         comm=comm+OrderSymbol()+"  Öåíà: "+DoubleToStr(OrderOpenPrice(),nd)+
              "  SL="+DoubleToStr(OrderStopLoss(),nd);
         if(OrderType()==OP_BUY) 
           {
            comm=comm+"("+DoubleToStr((OrderStopLoss()-OrderOpenPrice())/pp,0)+")\n";
            if(OrderStopLoss()-OrderOpenPrice()<LevelWLoss*pp) 
              {
               pBid=MarketInfo(OrderSymbol(),MODE_BID);
               if(pBid-OrderOpenPrice()>LevelProfit*pp) 
                 {
                  fm=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+LevelWLoss*pp,OrderTakeProfit(),CLR_NONE);
                 }
              }
           }
         if(OrderType()==OP_SELL) 
           {
            comm=comm+"("+DoubleToStr((OrderOpenPrice()-OrderStopLoss())/pp,0)+")\n";
            if(OrderStopLoss()==0 || OrderOpenPrice()-OrderStopLoss()<LevelWLoss*pp) 
              {
               pAsk=MarketInfo(OrderSymbol(),MODE_ASK);
               if(OrderOpenPrice()-pAsk>LevelProfit*pp) 
                 {
                  fm=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-LevelWLoss*pp,OrderTakeProfit(),CLR_NONE);
                 }
              }
           }
         if(fm) 
           {
            if(SoundAlert) PlaySound("alert2");
            break;
           }
        }
     }
   if(ShowComment) Comment(comm);
  }
//+------------------------------------------------------------------+

Comments