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!
Reply to Thread
Hasil 1 hingga 6 dari 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
    Tanggal Bergabung
    Feb 2014
    Location
    Pekanbaru
    Publikasi
    6
    Accumulated bonus
    1.48 USD (What is this?)
    Terima kasih
    0
    Terima kasih 3 Kali dalam 2 Pos

    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. <a href="http://indo.mt5.com/">Forex Portal MT5</a>
  3. The Following User Says Thank You to alixcool For This Useful Post:

    raden123 (01-14-2018)

  4. #2
    Orang Asing
    ----
     
    niam is an unknown quantity at this point niam's Avatar
    Tanggal Bergabung
    Jul 2012
    Publikasi
    1
    Accumulated bonus
    0.44 USD (What is this?)
    Terima kasih
    0
    Terima kasih 1 Kali dalam 1 Pos
    pertanyaannya kurang detail
    semua pair atau hanya pair tertentu

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

    lebih detail kali aja bisa lanjut

  5. The Following User Says Thank You to niam For This Useful Post:

    raden123 (01-14-2018)

  6. #3
    Orang Asing
    ----
     
    alixcool is an unknown quantity at this point alixcool's Avatar
    Tanggal Bergabung
    Feb 2014
    Location
    Pekanbaru
    Publikasi
    6
    Accumulated bonus
    1.48 USD (What is this?)
    Terima kasih
    0
    Terima kasih 3 Kali dalam 2 Pos
    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

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

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

  8. #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's Avatar
    Tanggal Bergabung
    Apr 2017
    Location
    Indonesia
    Publikasi
    940
    Accumulated bonus
    1294.32 USD (What is this?)
    Terima kasih
    999
    Terima kasih 1,059 Kali dalam 424 Pos
    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
    Kode:
    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

    Kode:
    void OnTick()
    {
    if(checkProfit(OP_BUY) > 10) { // code close order di sini }
    
    if(checkProfit(OP_SELL) > 50) { // code close order di sini }
    
    
    }

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

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

  10. #5
    Penggemar
    ----
     
    raden123 is just really nice raden123 is just really nice raden123 is just really nice raden123 is just really nice raden123's Avatar
    Tanggal Bergabung
    Jan 2018
    Publikasi
    349
    Accumulated bonus
    164.98 USD (What is this?)
    Terima kasih
    2,586
    Terima kasih 374 Kali dalam 200 Pos
    Quote Originally Posted by niam View 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
    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

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

    ahmadkh01r1 (01-14-2018)

  12. Lancer
  13. #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
    Tanggal Bergabung
    Jul 2013
    Location
    Indonesia
    Publikasi
    3,009
    Accumulated bonus
    494.14 USD (What is this?)
    Terima kasih
    1,833
    Terima kasih 521 Kali dalam 416 Pos
    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

  14. The Following 2 Users Say Thank You to ting tong For This Useful Post:

    Unregistered (2)

Reply to Thread

Memposting Izin

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