2 10 1234 ...
11 20 99

: MQL4

  1. #11
      kira-h
    Nov 2013
    6,242
    mohamed2012


    ,















  2. #12
      kira-h
    Nov 2013
    6,242


    MQL4 :
    OnInit OnTick OnDeinit

    ʡ ... ʡ .
    .












  3. #13

    Feb 2014
    57









  4. #14
      kira-h
    Nov 2013
    6,242
    sunegypt














  5. #15
      kira-h
    Nov 2013
    6,242

    ̡ :

    + OnTick :

    PHP:
    void CloseOrders(int type)
    {
     for (
    int cnt=0;cnt<OrdersTotal();cnt++)//      
     
    {
      
    bool s=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if (
    OrderType()==type&&OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo//         
      
    {
       
    bool c=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(OrderClosePrice(),Digits),30); //    
      
    }   
     }

    OnTick :
    :
    PHP:
    void OnTick() //            
    {
     if(
    Close[1]<Open[1])CloseOrders(OP_BUY); //         
     
    if(Close[1]>Open[1])CloseOrders(OP_SELL);//          

    + OnTick :
    PHP:
    void DeletePendingOrders(int type)
    {
     for(
    int i=0;i<OrdersTotal();i++)//       
     
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
     {
      if(
    OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo)//      
      
    {
       if(
    OrderType()==type//   
       
    {
        
    bool ret=OrderDelete(OrderTicket(),Red);//     
       
    }
      }
     }

    OnTick :
    :
    PHP:
    void OnTick()
    {
     if(
    Close[1]<Open[1])//              
     
    {
      
    DeletePendingOrders(OP_BUYLIMIT); //    
      
    DeletePendingOrders(OP_BUYSTOP); //    
     

     if(
    Close[1]>Open[1])//              
     
    {
      
    DeletePendingOrders(OP_SELLLIMIT); //    
      
    DeletePendingOrders(OP_SELLSTOP); //   
     












    kira-h ; 05-06-2015 04:18 PM




  6. #16
      kira-h
    Nov 2013
    6,242
    OnTick :
    PHP:

    void CloseBuyOrders
    () //    
    {
     for(
    int cnt=0;cnt<OrdersTotal();cnt++)
     {
      
    bool s=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(
    OrderMagicNumber()==MagicNo&&OrderSymbol()==Symbol())
      {
       if(
    OrderType()==OP_BUY)
       {
        
    bool c=OrderClose(OrderTicket(),OrderLots(),Bid,3);
       }
      }
     } 
    }  

    void CloseSellOrders()//    
    {
     for(
    int cnt=0;cnt<OrdersTotal();cnt++)
     {
      
    bool s=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(
    OrderMagicNumber()==MagicNo&&OrderSymbol()==Symbol())
      {
       if(
    OrderType()==OP_SELL)
       {
        
    bool c=OrderClose(OrderTicket(),OrderLots(),Ask,3);
       }
      }
     }

    void
    int double

    for
    OrderClose bool

    PHP:
    bool c=OrderClose(OrderTicket(),OrderLots(),Ask,3); 
    :
    PHP:
    OrderClose(OrderTicket(),OrderLots(),Ask,3); 
    Ask Bid

    3 slippage

    PHP:
    bool c=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage); 








    kira-h ; 05-06-2015 04:35 PM




  7. #17

    Feb 2014
    57













  8. #18
      kira-h
    Nov 2013
    6,242
    sunegypt




    ɡ












  9. #19

    May 2015
    61
    ... .. .. .. .









  10. #20
      kira-h
    Nov 2013
    6,242




    + :
    OnTick :
    PHP:
    double CalculMM()
    {
     
    double lot=MathCeil((AccountFreeMargin()*RiskPercent)/1000)/100
     if(
    lot<MarketInfo(Symbol(),MODE_MINLOT))lot=MarketInfo(Symbol(),MODE_MINLOT);
     if(
    lot>MarketInfo(Symbol(),MODE_MAXLOT))lot=MarketInfo(Symbol(),MODE_MAXLOT);
     return(
    NormalizeDouble(lot,2));

    OnTick :
    PHP:
    void OnTick()
    {
     if(
    UseRiskMM)Lots=CalculMM();



    :

    AccountBalance :
    .
    .

    AccountEquity :
    .
    .
    .

    AccountMargin :
    .. .
    .

    AccountFreeMargin :
    . .

    AccountFreeMargin












2 10 1234 ...