Mulai trading tanpa
risiko dan investasi
Dengan Bonus Permulaan 1000$
Dapatkan bonus
55%
ke akun anda!
Reply to Thread
Results 1 to 4 of 4

Thread: Kode menghitung profit yang sedang op buy dan op sell (masing-masing)

  1. #1
    Orang Asing
    ----
     
    alixcool is an unknown quantity at this point alixcool's Avatar
    Join Date
    Feb 2014
    Location
    Pekanbaru
    Posts
    6
    Accumulated bonus
    1.20 USD (What is this?)
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Kode menghitung profit yang sedang op buy dan op sell (masing-masing)

    Mohon bantuannya master2 bagaimana kode di MQL4 untuk menghitung profit yang sedang op buy dan op sell (masing-masing) ?

  2. Lancer
  3. #2
    Orang Asing
    ----
     
    niam is an unknown quantity at this point niam's Avatar
    Join Date
    Jul 2012
    Posts
    1
    Accumulated bonus
    0.30 USD (What is this?)
    Thanks
    0
    Thanked 0 Times in 0 Posts
    pertanyaannya kurang detail
    semua pair atau hanya pair tertentu

    opnya properti nya gmana, magic number, sama comment nya.

    lebih detail kali aja bisa lanjut

  4. #3
    Orang Asing
    ----
     
    alixcool is an unknown quantity at this point alixcool's Avatar
    Join Date
    Feb 2014
    Location
    Pekanbaru
    Posts
    6
    Accumulated bonus
    1.20 USD (What is this?)
    Thanks
    0
    Thanked 0 Times in 0 Posts
    saya skrg menggunakan code berikut :

    double ld_40 = 0;
    for (li_0 = 0; li_0 < OrdersTotal(); li_0++) {
    OrderSelect(li_0, SELECT_BY_POS, MODE_TRADES);
    if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic || OrderType() > OP_SELL) continue;
    ld_40 += OrderProfit();
    }
    if (ld_40 >= tp_in_money || g_count_264 > 0) {
    closeall();
    closeall();
    closeall();
    g_count_264++;
    if (total(0)+total(1) == 0) g_count_264 = 0;

    void closeall() {
    for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) {
    OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
    if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue;
    if (OrderType() > OP_SELL) OrderDelete(OrderTicket());
    else {
    if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
    else OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
    }
    }
    }

    tetapi itu jika profit (tp_in_money) sudah tercapai seluruh order di close, sementara saya mau memisanhkan masing-masing tp_in_money untuk posisi buy dan tp_in_money untuk posisi sell

  5. <a href="http://www.mt5.com/id/forex_humor">Forex Portal MT5</a>
  6. #4
    Pecandu
    Yeehaw
     
    inLuk has a spectacular aura about inLuk has a spectacular aura about inLuk's Avatar
    Join Date
    Apr 2017
    Posts
    566
    Accumulated bonus
    240.15 USD (What is this?)
    Thanks
    12
    Thanked 162 Times in 106 Posts
    Quote Originally Posted by alixcool View Post
    saya skrg menggunakan code berikut :

    double ld_40 = 0;
    for (li_0 = 0; li_0 < OrdersTotal(); li_0++) {
    OrderSelect(li_0, SELECT_BY_POS, MODE_TRADES);
    if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic || OrderType() > OP_SELL) continue;
    ld_40 += OrderProfit();
    }
    if (ld_40 >= tp_in_money || g_count_264 > 0) {
    closeall();
    closeall();
    closeall();
    g_count_264++;
    if (total(0)+total(1) == 0) g_count_264 = 0;

    void closeall() {
    for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) {
    OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
    if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue;
    if (OrderType() > OP_SELL) OrderDelete(OrderTicket());
    else {
    if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
    else OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
    }
    }
    }

    tetapi itu jika profit (tp_in_money) sudah tercapai seluruh order di close, sementara saya mau memisanhkan masing-masing tp_in_money untuk posisi buy dan tp_in_money untuk posisi sell
    saya ada.. nanti saya posting d sini

    ---------- Post added at 04:06 PM ---------- Previous post was at 11:52 AM ----------

    here you go

    pertama kita buat fungsi buat mendapatkan total akumulasi profit dari jenis entry nya
    Code:
    double checkProfit(int ope_)
      {
       double duit=0; 
       if(OrdersTotal()>0)
         {
          for(int x=OrdersTotal(); x>=0; x--)
            {
             if(OrderSelect(x,SELECT_BY_POS,MODE_TRADES))
               {
                if(OrderType()==ope_) {duit+=OrderProfit();}
               }
            }
         }
       return(duit);
      }
    kemudian kita bisa panggil untuk kemudian di gunakan seperti melakukan close order ketika nilai yg di dapat melebihi nilai inputan

    Code:
    void OnTick()
    {
    if(checkProfit(OP_BUY) > 10) { // code close order di sini }
    
    if(checkProfit(OP_SELL) > 50) { // code close order di sini }
    
    
    }
    -- Telegram @inLuk --

    kunjungi thread saya:

Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts