Open Forex4you Account

Server Ãѹ EA 1000 / »Õ

ÊÑ觪×éͤÙèÁ×Í¡ÒÃâ»ÃááÁ MQL4

Author Topic: à¢Õ¹ÍÕàͨҡàà·è§à·Õ¹ààµèÁѹà»Ô´»Ô´·Õèà´ÕÂǡѹ  (Read 12240 times)

¤Ø¨¹ÅÔ§ËÅѺ(-.-)

  • Full Member
  • ***
  • Posts: 105
Áѹà»Ô´µÒÁà§×è͹ààµè¨ÐãËé»Ô´·Õèà§×è͹䧵èÍä»·Óä§ÍÐ ¢Íº¤Ø³¤Ñº

extern double    Lots=0.1;


extern int Slippage=3;
extern int MagicNumber1=2001;
extern int MagicNumber2=2002;
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----



int i;


//-------------------------------------------------------------------+
//Check open orders
//-------------------------------------------------------------------+
if(OrdersTotal()>0){
  for(i=1; i<=OrdersTotal(); i++)         
     {
      if (OrderSelect(i-1,SELECT_BY_POS)==true)
        {
          if(OrderMagicNumber()==MagicNumber1) {int halt1=1;}
          if(OrderMagicNumber()==MagicNumber2) {int halt2=1;}

        }
     }
}
//-------------------------------------------------------------------+

//-----------------------------------------------------------------
// Bar checks
//-----------------------------------------------------------------

 if(iOpen(NULL,0,1)<iClose(NULL,0,1)) int BarOneUp=1;
 if(iOpen(NULL,0,1)>iClose(NULL,0,1)) int BarOneDown=1;

 if(iOpen(NULL,0,2)<iClose(NULL,0,2)) int BarTwoUp=1;
 if(iOpen(NULL,0,2)>iClose(NULL,0,2)) int BarTwoDown=1;

 if(iOpen(NULL,0,3)<iClose(NULL,0,3)) int BarThreeUp=1;
 if(iOpen(NULL,0,3)>iClose(NULL,0,3)) int BarThreeDown=1;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 



 
 if(BarOneDown==1&&BarTwoDown==1&&BarThreeUp==1&&halt2!=1&&Volume[1]>Volume[2]&&Volume[2]>Volume[3]){
 int opensell1=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"sell",MagicNumber2,0,Red);
   
 }
    if(BarOneDown==1&&BarTwoDown==1&&BarThreeUp==1){CloseAllSellTrades();}
   
                                       

 
 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//-------------------------------------------------------------------
   return(0);
  }
//+------------------------------------------------------------------+



void CloseAllSellTrades() {
    for (int i = OrdersTotal() - 1; i >= 0; i--) {
      int closesell = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);   
      if (OrderSymbol() == Symbol() && (OrderMagicNumber() == MagicNumber2))
         if (OrderType() == OP_SELL)
           // OrderClose( OrderTicket(), OrderLots(), Ask, SlippageClose);
           {
           RefreshRates();         
           for(int try = 1; try <= 2; try++)                               
           if (!OrderClose( OrderTicket(), OrderLots(), Ask, Slippage))
            {  Print("Îøèáêà ", GetLastError());
               Print("Íå óäàëîñü çàêðûòü îðäåð, ïîïûòêà ", try);
               Sleep(1000);
               RefreshRates();
            }
            else           
               break;                             
         }
   }
   
}

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 2386
ÍèÒ¹áÅéǧ§ áµè¾Í¨Ñºã¨¤ÇÒÁä´é ËÒ¡µéͧ¡ÒÃãËéÁѹ»Ô´ã¹à§×è͹ä¢ä˹ ¡çµéͧÊÃéÒ§à§×è͹ä¢ãËéÁѹµÃǨÊͺ¡è͹¤ÃѺ

¤Ø¨¹ÅÔ§ËÅѺ(-.-)

  • Full Member
  • ***
  • Posts: 105
äÁèãËéÁѹ¹Ñº«é͹¡Ñ¹ ÃÐËÇèÒ§à»Ô´¡Ñº»Ô´
ÊÁÁصÔà»Ô´ÍÍà´ÍÃì ÍÕàͨѺä´éÇèÒàà·è§à·Õ¹ 3 àà·è§àÃÕ§¡Ñ¹ ¨Ð»Ô´ÍÍà´ÍÃìã¹àà·è§·Õè 4
¨ÐäÁèãËéÍÕàÍ´Ùàà·è§·Õè 4 ààµèãËé´Ùàà·è§·Õè 5 à»ç¹µé¹ä» à»Ô´ÍÍà´ÍÃì¶Ñ´ä»
ÊÃØ»äÁèãËéÍÕàÍ´Ù  àà·è§·Õèà»Ô´ÍÍà´ÍÃì ¡Ñº»Ô´ÍÍà´ÍÃì ààµèãËé´Ùàà·è§¶Ñ´ä»
 ??? ::)
« Last Edit: Á¡ÃÒ¤Á 31, 2015, 03:48:35 pm by ¤Ø¨¹ÅÔ§ËÅѺ(-.-) »

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 2386
ãªéàÃ×èͧ¨Ó¹Ç¹ á·è§à·Õ¹à¢éÒªèǤÃѺ ¤ÓÊÑè§ Bar ¨Ðà»ç¹µÑǺ͡¨Ó¹Ç¹á·è§à·Õ¹㹡ÃÒ¿·Õè ea  à»Ô´ÍÂÙè  ¤Ø³ÊÃéÒà§×è͹䢵ÃǨÊͺÇèҨӹǹ Bar à»ÅÕè¹á»Å§ä»¨Ò¡á·è§·Õèà»Ô´ËÃ×ÍÂѧ¶éÒà»ÅÕè¹áŧáÅéǶ֧à»Ô´ order ¤ÃѺ