Forex Community Place

Dapatkan hingga
$50000
karena mengundang teman
untuk memperoleh Bonus StartUp
dari InstaForex
Tidak perlu investasi!
Mulai trading tanpa
risiko dan investasi
Dengan Bonus Permulaan 1000$
Dapatkan bonus
55%
ke akun anda!
Results 1 to 6 of 6

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 USD (What is this?)
    Thanks
    0
    Thanked 3 Times in 2 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. The Following User Says Thank You to alixcool For This Useful Post:

    raden123 (01-14-2018)

  3. #2
    Orang Asing
    ----
     
    niam is an unknown quantity at this point niam's Avatar
    Join Date
    Jul 2012
    Posts
    1
    Accumulated bonus
    0 USD (What is this?)
    Thanks
    0
    Thanked 1 Time in 1 Post
    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. The Following User Says Thank You to niam For This Useful Post:

    raden123 (01-14-2018)

  5. #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 USD (What is this?)
    Thanks
    0
    Thanked 3 Times in 2 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

  6. The Following 2 Users Say Thank You to alixcool For This Useful Post:

    ahmadkh01r1 (01-14-2018), raden123 (01-14-2018)

  7. #4
    Orang Lama
    Mengintai
     
    inLuk has much to be proud of inLuk has much to be proud of inLuk has much to be proud of inLuk has much to be proud of inLuk has much to be proud of inLuk has much to be proud of inLuk has much to be proud of inLuk has much to be proud of inLuk has much to be proud of inLuk has much to be proud of inLuk's Avatar
    Join Date
    Apr 2017
    Location
    Indonesia
    Posts
    1,098
    Accumulated bonus
    1551 USD (What is this?)
    Thanks
    1,132
    Thanked 1,518 Times in 595 Posts
    Quote Originally Posted by alixcool     
    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 }
    
    
    }

  8. The Following 2 Users Say Thank You to inLuk For This Useful Post:

    ahmadkh01r1 (01-14-2018), raden123 (01-14-2018)

  9. #5
    Banned
    ----
     
    raden123 has a brilliant future raden123 has a brilliant future raden123 has a brilliant future raden123 has a brilliant future raden123 has a brilliant future raden123 has a brilliant future raden123 has a brilliant future raden123 has a brilliant future raden123 has a brilliant future raden123 has a brilliant future raden123 has a brilliant future raden123's Avatar
    Join Date
    Jan 2018
    Posts
    1,079
    Accumulated bonus
    765 USD (What is this?)
    Thanks
    2,979
    Thanked 1,939 Times in 804 Posts
    Quote Originally Posted by niam     
    pertanyaannya kurang detail
    semua pair atau hanya pair tertentu

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

    lebih detail kali aja bisa lanjut
    Kira-kira kalau di fair eur/usd gmna cara perhitungannya master? Karena menurut pengamatan pribadi saya di fair eur usd yg gerakannya sangat signifikan setiap hari dibanding fair-fair yang lain,ini cuma analisa pribadi saja tapi master, mohon penjelasan cara perhitungannya hanya di fair eur/usd

  10. The Following User Says Thank You to raden123 For This Useful Post:

    ahmadkh01r1 (01-14-2018)

  11. <a href="">Forex Portal MT5</a>
  12. #6
    Poster Lama
    ----
     
    ting tong is a glorious beacon of light ting tong is a glorious beacon of light ting tong is a glorious beacon of light ting tong is a glorious beacon of light ting tong is a glorious beacon of light ting tong is a glorious beacon of light ting tong's Avatar
    Join Date
    Jul 2013
    Location
    Indonesia
    Posts
    3,019
    Accumulated bonus
    495 USD (What is this?)
    Thanks
    1,840
    Thanked 546 Times in 436 Posts
    untuk hitung jumlah order, pip, jumlah profit loss.

    PHP Code:
    for(i=0;i<ArraySize(TradePairs);i++)
            {
        
             
    bpos[i]=0;
             
    spos[i]=0;
             
    blots[i]=0;
             
    slots[i]=0;
             
    bprofit[i]=0;
             
    sprofit[i]=0;
             
    tprofit[i]=0;
             
    Tpip[i]=0;
             
    Tspip[i]=0;
             
    Topip[i]=0;
             
    pairinfo[i].lastopenprice 0.0;
            }
          for(
    i=0;i<OrdersTotal();i++)
            {
             if(
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
                break;

             for(
    j=0;j<ArraySize(TradePairs);j++)
             if (
    StringSubstr(pairinfo[j].symbol,0,6) == StringSubstr(OrderSymbol(),0,6)) 
               {
                if((
    TradePairs[j]==OrderSymbol() || TradePairs[j]=="") && OrderMagicNumber()==Magic_Number)
                  {
                   
    TradePairs[j]=OrderSymbol();
                   
    tprofit[j]=tprofit[j]+OrderProfit()+OrderSwap()+OrderCommission();
                   if(
    OrderType()==0){ bprofit[j]+=OrderProfit()+OrderSwap()+OrderCommission(); }
                   if(
    OrderType()==1){ sprofit[j]+=OrderProfit()+OrderSwap()+OrderCommission(); }
                   if(
    OrderType()==0){ blots[j]+=OrderLots(); }
                   if(
    OrderType()==1){ slots[j]+=OrderLots(); }
                   if(
    OrderType()==0){ bpos[j]+=+1; }
                   if(
    OrderType()==1){ spos[j]+=+1; }
                   if(
    OrderOpenTime()>pairinfo[j].lasttradetimepairinfo[j].lasttradetime=OrderOpenTime();
                   if(
    OrderType()==0)totalBUY totalBUY+OrderProfit()+OrderSwap()+OrderCommission();
                   if(
    OrderType()==1)totalSELL totalSELL+OrderProfit()+OrderSwap()+OrderCommission();
                   if(
    OrderType()==0)Tpip [j]+= (MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/pairinfo[j].PairPip;
                   if(
    OrderType()==1)Tspip [j]+=(OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_ASK))/pairinfo[j].PairPip;
                   
    Topip[j]=(Tpip[j]+Tspip[j]); 
    jika ingin skenario close saat melebihi jumlah profit yang di tentukan bisa gunakan ini.
    PHP Code:
    //+------------------------------------------------------------------+
    void close_profit()
      {
       
    int cnt 0;
       for(
    cnt OrdersTotal()-1cnt >= 0cnt--)
         {
          if(
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)==true)
             if(
    OrderProfit()>0)
               {
                if(
    OrderType()==OP_BUY && OrderMagicNumber()==Magic_Number)
                   
    ticket=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Violet);
                if(
    OrderType()==OP_SELL && OrderMagicNumber()==Magic_Number)
                   
    ticket=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5,Violet);
                if(
    OrderType()>OP_SELL)
                   
    ticket=OrderDelete(OrderTicket());
               }
         }
      }
    //+------------------------------------------------------------------+
    void close_loss()
      {
       
    int cnt 0;
       for(
    cnt OrdersTotal()-1cnt >= 0cnt--)
         {
          if(
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)==true)
             if(
    OrderProfit()<0)
               {
                if(
    OrderType()==OP_BUY && OrderMagicNumber()==Magic_Number)
                   
    ticket=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Violet);
                if(
    OrderType()==OP_SELL && OrderMagicNumber()==Magic_Number)
                   
    ticket=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5,Violet);
                if(
    OrderType()>OP_SELL)
                   
    ticket=OrderDelete(OrderTicket());
               }
         }
      } 
    Concentrate on your Losses and Profits will take care of itself

  13. The Following 5 Users Say Thank You to ting tong For This Useful Post:

    Unregistered (2)

Posting Permissions

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