1. Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)
    Dismiss Notice

Bug anyBody Fix this code For me plz

Discussion in 'Belajar MQL dari Nol' started by john mith, 29 Jun 2020.

  1. john mith

    john mith New Member

    Equity
    Credit
    Ref Point
    When I am using "strict" mode (#property strict) in a EA to generate an ex4 file, I found this ex4 file has some problem: any body can Fix this Code For Me plz :)

    double subLotSize()
    {
    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,Lot_Digits));
    }
    double profit(int type){
    double c;
    for(int i=0;i<OrdersTotal();i++){
    bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()==Symbol()&&OrderType()==type&&OrderMagicNumber()==MagicNumber){
    c=c+OrderProfit();
    }
    }
    return(c);
    }
    double AvTP(int type){
    double Price;double lots;
    for(int i=0;i<=OrdersTotal();i++){
    bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber&&OrderType()==type){
    Price+=OrderOpenPrice()*OrderLots();
    lots+=OrderLots();
    }
    }
    if(Price!=0&&lots!=0) return(Price/lots);
    return(0);
    }
    //+---------------------------------------------------------------------------------+
    [​IMG]
     
  2. garago

    garago Member Credit Hunter

    Equity
    Credit
    Ref Point
    return (NormalizeDouble(lot,MarketInfo(Symbol(),MODE_DIGITS)));

    and

    double c=0;
    double Price=0;double lots=0;
     

Share This Page