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

Suggestion Macam mana nak ejas code ni buatkan dia tolak -1 layer setiap group ??

Discussion in 'Belajar MQL dari Nol' started by kurama87, 29 Apr 2024.

  1. kurama87

    kurama87 Member Credit Hunter

    Equity
    Credit
    Ref Point
    Code:
    //| Total Order
    
    //+------------------------------------------------------------------+
    
    int TotalOrder(int ordertype = -1)//ok
    
      {
    
       int Order = 0;
    
    
    
       for(int i = 0; i < OrdersTotal(); i++)
    
         {
    
          if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
    
            {
    
             if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
    
               {
    
                if(ordertype == -1)
    
                   Order++;
    
                else
    
                   if(ordertype == OrderType())
    
                      Order++;
    
               }
    
            }
    
         }
    
    
    
       return(Order);
    
      }
    
    //+------------------------------------------------------------------+
    
    //| Setup Lot
    
    //+------------------------------------------------------------------+
    
    double SetupLot(int orderType)
    
      {
    
       double lot    = 0, firstLot = 0,multiplier = Multiplier_,
    
              MinLot = MarketInfo(Symbol(),MODE_MINLOT),
    
              MaxLot = MarketInfo(Symbol(),MODE_MAXLOT),
    
              lotStep  = MarketInfo(Symbol(),MODE_LOTSTEP);
    
       int    lotDigit = 1;
    
       if(lotStep == 0.01)
    
          lotDigit = 2;
    
       if(lotStep == 0.001)
    
          lotDigit = 3;
    
    //===============================================================================================
    
    //if(TotalOrder(orderType)+1 >= AtLevelMulti) multiplier = LotExponent;
    
    
    
       if(MathMod(TotalOrder(orderType)+1,Layer_Per_Group)==1)
    
          multiplier = LotExponent;
    
       
    
    //===============================================================================================
    
       for(int i = 0; i < OrdersTotal(); i++)
    
         {
    
          if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
    
            {
    
             if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
    
               {
    
                if(OrderType() == orderType)
    
                   lot = MathMax(lot,OrderLots());
    
               }
    
            }
    
         }
    
    
    
       if(lot == 0)
    
         {
    
          if(Lots_By_Risk==0)
    
             lot = Lots_Manual;
    
          else
    
             lot = AccountBalance()*Lots_By_Risk/10000;
    
         }
    
       else
    
         {
    
          if(multiplier > 0)
    
            {
    
             lot *= multiplier;
    
             lot += (0.004);
    
            }
    
          else
    
            {
    
             if(Lots_By_Risk==0)
    
                lot = Lots_Manual;
    
             else
    
                lot = AccountBalance()*Lots_By_Risk/10000;
    
            }
    
         }
    
    
    
    
    
       lot = NormalizeDouble(lot,lotDigit);
    
       if(lot < MinLot)
    
          lot = MinLot;
    
       if(lot > MaxLot)
    
          lot = MaxLot;
    
    
    
       return(lot);
    
      }

    Hi nak tanya, mcm mana nk buat code ni dia tolak -1 layer untuk each group tapi starting dari group ke dua dan seterusnya lah.. dan bila -1 layer hilang dari setiaap group, dia akan tinggal hanya satu layer je..

    dan lepas tu nak buat 1 layer tu dan layer seterusnya follow pipstep dan lot martingale exponent.. takde lagi group..

    contoh simple mcm ni

    kita set layer per group 5

    guunaa pipstep 30
    exponent 1.5

    so setiap 30 pip dia akan bukak same lot size in group

    0.01x5
    lepas tu layer group kedua akan ada martingale skit

    0.02x4 sebab dah tolak -1 layer

    0.03x3 (ni kira2 je kalau ikut martingale lot)

    0.07x2

    0.14x1

    dan 0.28, 0.56 dan seterusnya dia follow layer pipstep lot exponent
     

Share This Page