3 10 12345 ...
21 30 99

: MQL4

  1. #21
      kira-h
    Nov 2013
    6,620
    +

    :
    :

    + :
    OnTick :

    PHP:
    double LastOrderProfit()
    {
     for(
    int i=OrdersHistoryTotal()-1;i>=0;i--)
     {
      
    bool select=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(
    OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo)
      {
       
    p=OrderProfit();
      }
     }
     return(
    p);

    void OnTick :
    PHP:
    void CalculMP()
    {
     if(
    LastOrderProfit()<0)NewLots=LastOrderLots()*LotsMpOnLoss;
     if(
    LastOrderProfit()>0)NewLots=Lots;

    LotsMpOnLoss :
    PHP:
    input double LotsMpOnLoss=1.5
    NewLots OnTick Lots
    :
    PHP:
    double NewLots

    void SellOrder()
    {
     
    bool ticket=OrderSend(Symbol(),OP_SELL,NewLots,Bid,Slippage,0,0,"Kira-h",MagicNo,0,Red);

    : LastOrderLots()*LotsMpOnLoss LotsMpOnLoss ( double ) x,xxx ɡ
    !

    x,xxx x,xx
    0.012 0.02
    NormalizeDouble :
    PHP:
    MathMin(NormalizeDouble(LastOrderLots()*LotsMpOnLoss,2
    :
    PHP:
    MarketInfo(Symbol(),MODE_MAXLOT
    :

    PHP:
    input string  MM="---------- Money Management-----------";
    input double  Lots=0.01
    input bool UseMultiply=false;
    input double LotsMpOnLoss=1.5;

    double NewLots

    void OnTick()
    {
     if(
    UseMultiply)CalculMP();
    }

    void CalculMP()
    {
     if(
    LastOrderProfit()<0)
     {
      
    NewLots=MathMin(NormalizeDouble(LastOrderLots()*LotsMpOnLoss,2),MarketInfo(Symbol(),MODE_MAXLOT));
     } 
     if(
    LastOrderProfit()>0)NewLots=Lots;

    NewLots=Lots
    :
    2 NormalizeDouble 0.01 0.1 1


    http://www.forexprog.com/vb/showthre...AC%D9%8A%D8%A9










    kira-h ; 05-10-2015 01:40 PM




  2. #22
      kira-h
    Nov 2013
    6,620
    LastOrderLots() OnTick :
    PHP:
    double LastOrderLots()
    {
     for(
    int i=OrdersHistoryTotal()-1;i>=0;i--)
     {
      
    bool select=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(
    OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo)
      {
       
    l=OrderLots();
      }
     }
     return(
    l);



    + :

    ɡ ( OnTick):
    PHP:
    double LastOrderLots()
    {
     
    double c;
     for(
    int i=0;i<OrdersTotal();i++)
     {
      
    bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(
    OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo)
      {
       
    c=OrderLots();
      }
     }
     return(
    c);

    OnTick :
    PHP:
    void CalculMP()
    {
     
    NewLots=MathMin(NormalizeDouble(LastOrderLots()*LotsMpOnLoss,2),MarketInfo(Symbol(),MODE_MAXLOT));


    " OnTick" void int double OnTick OnTick .


    http://www.forexprog.com/vb/showthre...AC%D9%8A%D8%A9










    kira-h ; 05-10-2015 02:34 PM




  3. #23
      kira-h
    Nov 2013
    6,620
    almeedi
    ... .. .. .. .

    ߡ .
    ɡ ɡ ߡ
    .













  4. #24
      kira-h
    Nov 2013
    6,620
    :

    + :

    PHP:
    //  
    input string  MM="---------- Money Management-----------"
    input double  Lots=0.01;  //  
    input bool UseMultiply=false//   
    input double LotsMpOnLoss=1.5;  //      

    //  
    double NewLots;  //          

    //   ( )        
    void OnTick() 

     if(
    UseMultiply)CalculMP(); //        
    SellOrder(); //  


    double LastOrderProfit() //      

     for(
    int i=OrdersHistoryTotal()-1;i>=0;i--) //  
     

      
    bool select=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); 
      if(
    OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo// 
      

       
    p=OrderProfit(); // 
      

     } 
     return(
    p); //    
    }  

    double LastOrderLots() //       

     for(
    int i=OrdersHistoryTotal()-1;i>=0;i--) // 
     

      
    bool select=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); 
      if(
    OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo//  
      

       
    l=OrderLots(); //  
      

     } 
     return(
    l); //  
    }  

    void CalculMP() //    

     if(
    LastOrderProfit()<0//      
     

      
    NewLots=MathMin(NormalizeDouble(LastOrderLots()*LotsMpOnLoss,2),MarketInfo(Symbol(),MODE_MAXLOT)); 
    //              ɡ               
     
    }  
     if(
    LastOrderProfit()>0)NewLots=Lots//               
    }  

    void SellOrder() //    

     
    bool ticket=OrderSend(Symbol(),OP_SELL,NewLots,Bid,Slippage,0,0,"Kira-h",MagicNo,0,Red); 
    //            

    + :

    PHP:
    input string  MM="---------- Money Management-----------"
    input double  Lots=0.01
    input bool UseMultiply=false;
    input double LotsMpOnLoss=1.5

    double NewLots;

    void OnTick() 

     if(
    UseMultiply)CalculMP(); 
    SellOrder(); 



    double LastOrderLots() //     

     for(
    int i=0;i<OrdersTotal();i++) //  
     

      
    bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); 
      if(
    OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo
      { 
       
    l=OrderLots(); //  
      

     } 
     return(
    l); //  
    }  

    void CalculMP() //    

     
    NewLots=MathMin(NormalizeDouble(LastOrderLots()*LotsMpOnLoss,2),MarketInfo(Symbol(),MODE_MAXLOT)); 
    }  

    void SellOrder() //    

     
    bool ticket=OrderSend(Symbol(),OP_SELL,NewLots,Bid,Slippage,0,0,"Kira-h",MagicNo,0,Red); 

    ʡ ...









    kira-h ; 05-10-2015 03:51 PM




  5. #25

    Mar 2014
    508








    [SIGPIC][/SIGPIC]

  6. #26
      kira-h
    Nov 2013
    6,620













  7. #27
      kira-h
    Nov 2013
    6,620
    :
    + 50
    ()



    OnTick

    :
    PHP:
    double s1=iSAR(NULL,S_TimeFrame,Step,Maximum,1);
    double s2=iSAR(NULL,S_TimeFrame,Step,Maximum,2); 
    S_TimeFrame
    Step Maximum

    :
    PHP:
    double m=iMA(NULL,M_TimeFrame,period,m_shift,m_method,applied_price,1); 
    M_TimeFrame
    period m_shift m_method applied_price

    :
    PHP:
    double st=iStochastic(NULL,St_TimeFrame,K_period,D_period,Slowing,ma_method,price_field,MODE_MAIN,1); 
    St_TimeFrame
    K_period - D_period - Slowing - ma_method - price_field
    MODE_MAIN
    : MODE_SIGNAL MODE_MAIN

    :
    PHP:
     input string Sar="------------Parabolic Sar Settings------------"
     
    input int TimeFrameS=60
     
    input double Step=0.02;
     
    input double Maximum=0.2;
     
     
    input string ma="------------Movine Average Settings------------";
     
    input int M_TimeFrame=1440;
     
    input int period=14;
     
    input double m_shift=0;
     
    input int m_method=0;
     
    input int applied_price=0;
     
     
    input string Sto="------------Stochastic Settings------------";
     
    input int St_TimeFrame=60;
     
    input int K_period=5;
     
    input int D_period=3;
     
    input int Slowing=3;
     
    input int ma_method=0;
     
    input int price_field=0
    int ( ) 1, 5 ,15 ,30 ,60, 240, 1440 int double

    :


    PHP:
    if(Open[1]<s1&&Open[1]>s2
    :
    PHP:
    if(Close[1]<m
    80 :
    PHP:
    if(st>50
    :
    PHP:
    if(Open[1]>s1&&Open[1]<s2)
    if(
    Close[1]>m)
    if(
    st<50
    :
    PHP:
    if(Open[1]<s1&&Open[1]>s2&&Close[1]<m&&st>50
    {
     
    SellOrder();

    :
    PHP:
    if(Open[1]>s1&&Open[1]<s2&&Close[1]>m&&st<50)
    {
     
    BuyOrder();

    :
    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 (
    lot);

    :
    PHP:
    input string  MM="----------- Money Management-------------";
    extern double  Lots=0.01
    extern bool UseRiskMM=false
    :
    PHP:
    void CalculMP()
    {
     if(
    LastOrderProfit()<0)NewLots=MathMin(NormalizeDouble(LastOrderLots()*LotsMpOnLoss,2),MarketInfo(Symbol(),MODE_MAXLOT));
     if((
    LastOrderProfit()>=0)||(NewLots>MaxLots))NewLots=Lots;

    ʡ NewLots=Lots

    :
    PHP:
    double LastOrderProfit()
    {
     
    double c;
     for(
    int i=OrdersHistoryTotal()-1;i>=0;i--)
     {
      
    bool select=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(
    OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo)
      {
       
    c=OrderProfit();
      }
     }
     return(
    c);

    :

    PHP:
    double LastOrderLots()
    {
     for(
    int i=OrdersHistoryTotal()-1;i>=0;i--)
     {
      
    bool select=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      
    double lots=OrderLots();
      if(
    OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo)
      {
       return(
    lots);
      }
     }
     return(
    0);

    :
    PHP:
    input string  MP="----------- Money P Management-------------";
    input bool UseMultiplier=false;
    input double LotsMpOnLoss=1.5,MaxLots=2
    NewLots OnTick :
    PHP:
    double NewLots
    OnTick :
    PHP:
    void OnTick()
    {
     if((
    UseRiskMM&&UseMultiplier)||(!UseRiskMM&&!UseMultiplier)){NewLots=Lots;}
     if(
    UseRiskMM&&!UseMultiplier){NewLots=CalculMM();}
     if(
    UseMultiplier&&!UseRiskMM){CalculMP();}

    UseMultiplier UseRiskMM true false ( )
    UseMultiplier =false UseMultiplier! ! false
    UseMultiplier =true UseMultiplier ! true

    :
    NewLots=Lots
    NewLots=CalculMM


    :
    PHP:
    if(Orderscnt()<1
    1

    OnTick :
    PHP:
    int Orderscnt()
    {
     
    int cnt=0;
     for(
    int i=0;i<OrdersTotal();i++)
     {
      if(
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {
       if(
    OrderSymbol()==Symbol()&&MagicNo==OrderMagicNumber())
       {
        
    cnt++;
       }
      }
     }
     return(
    cnt);

    :
    PHP:
    void BuyOrder()
    {
     if(
    Orderscnt()<1)
     {
      
    double SL=Ask-Stoploss*point ;
      if(
    Stoploss==0)SL=0;
      
    double TP=Ask+Takeprofit*point ;
      if(
    Takeprofit==0)TP=0;
      
    int ticket=-1;
      
    ticket=OrderSend(Symbol(),OP_BUY,NewLots,Ask,Slippage,0,0,"Kira-h",MagicNo,0,Blue);
      if(
    ticket>-1)
      {
       
    bool select=OrderSelect(ticket,SELECT_BY_TICKET);
       
    bool ret=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,0,Blue);
      }     
     }

    :
    PHP:
    void SellOrder()
    {
     if(
    Orderscnt()<1)
     {
      
    double SL=Bid+Stoploss*point ;
      if(
    Stoploss==0)SL=0;
      
    double TP=Bid-Takeprofit*point ;
      if(
    Takeprofit==0)TP=0;
      
    int ticket=-1;
      
    ticket=OrderSend(Symbol(),OP_SELL,NewLots,Bid,Slippage,0,0,"Kira-h",MagicNo,0,Red);
      if(
    ticket>-1)
      {
       
    bool select=OrderSelect(ticket,SELECT_BY_TICKET);
       
    bool ret=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,0,Red);
      }     
     }

    :
    point 3 4 5
    OrderModify ѡ ( ECN STP)

    :
    Takeprofit
    Stoploss
    Slippage
    "Kira-h"
    MagicNo

    :
    PHP:
    input string  OM="---------- Order Management-----------";
    input int Takeprofit=50;
    input int Stoploss=20;
    input int Slippage=3;
    input int MagicNo=2015


    PHP:
    double point;
     
    int digits
    OnInit
    :
    PHP:
     if(Digits<4)
       {
          
    point=0.01;
          
    digits=2;
       }
       else
       {
          
    point=0.0001;
          
    digits=4;
       } 
    Digits<4 2 3 point=0.01 digits=2

    else Digits<4 Digits>=4
    4 5
    point=0.0001 digits=4
    Point point Digits digits

    OnTick :
    PHP:
    //+------------------------------------------------------------------+
    //| FUNCTION DEFINITIONS   TrailingStop                              |
    //+------------------------------------------------------------------+
    void MoveTrailingStop()
    {
     for(
    int cnt=0;cnt<OrdersTotal();cnt++)
     {
      
    bool select=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(
    OrderType()<=OP_SELL&&OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo)
      {
       if(
    OrderType()==OP_BUY)
       {
        if(
    TrailingStop>0&&NormalizeDouble(Ask-TrailingStep*point,Digits)>NormalizeDouble(OrderOpenPrice()+TrailingStop*point,Digits))  
        {                 
         if((
    NormalizeDouble(OrderStopLoss(),Digits)<NormalizeDouble(Bid-TrailingStop*point,Digits))||(OrderStopLoss()==0))
         {
          
    bool modify=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-TrailingStop*point,Digits),OrderTakeProfit(),0,Blue);
         }
        }
       }
       else 
       {
        if(
    TrailingStop>0&&NormalizeDouble(Bid+TrailingStep*point,Digits)<NormalizeDouble(OrderOpenPrice()-TrailingStop*point,Digits))  
        {                 
         if((
    NormalizeDouble(OrderStopLoss(),Digits)>(NormalizeDouble(Ask+TrailingStop*point,Digits)))||(OrderStopLoss()==0))
         {
          
    modify=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+TrailingStop*point,Digits),OrderTakeProfit(),0,Red);
         }
        }
       }
      }
     }
    }
    void MoveBreakEven()
    {
     for(
    int cnt=0;cnt<OrdersTotal();cnt++)
     {
      
    bool select=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(
    OrderType()<=OP_SELL&&OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo)
      {
       if(
    OrderType()==OP_BUY)
       {
        if(
    BreakEven>0)
        {
         if(
    NormalizeDouble((Bid-OrderOpenPrice()),Digits)>BreakEven*point)
         {
          if(
    NormalizeDouble((OrderStopLoss()-OrderOpenPrice()),Digits)<0)
          {
           
    bool modifyOrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()+BreakEvenPips*point,Digits),OrderTakeProfit(),0,Blue);
          }
         }
        }
       }
       else
       {
        if(
    BreakEven>0)
        {
         if(
    NormalizeDouble((OrderOpenPrice()-Ask),Digits)>BreakEven*point)
         {
          if(
    NormalizeDouble((OrderOpenPrice()-OrderStopLoss()),Digits)<0)
          {
           
    modifyOrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-BreakEvenPips*point,Digits),OrderTakeProfit(),0,Red);
          }
         }
        }
       }
      }
     }

    OnTick :
    PHP:
    void OnTick()
    {
     if(
    TrailingStop>0){MoveTrailingStop();}
     if(
    BreakEven>0){MoveBreakEven();}















  8. #28

    Feb 2014
    57









  9. #29
      kira-h
    Nov 2013
    6,620
    sunegypt
    ߡ












  10. #30

    Mar 2015
    52











3 10 12345 ...