Forex Community Place

Dapatkan hingga
$50000
karena mengundang teman
untuk memperoleh Bonus StartUp
dari InstaForex
Tidak perlu investasi!
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 Collapse Post
    Orang Asing
    ----
     
    alixcool is an unknown quantity at this point alixcool's Avatar
    Join Date
    Feb 2014
    Location
    Pekanbaru
    Posts
    6
    Accrued Payments
    1 USD (What is this?)
    Thanks
    0
    Thanked 3 Times in 2 Posts
    SubscribeSubscribe
    Subscribed: 0

    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) ?

    Though trading on financial markets entails high risk, still it can generate extra income on condition that you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  2. User Say Thank:

    raden123 (01-14-2018)

  3. <a href="">Forex Portal MT5</a>
  4. #2 Collapse Post
    Orang Asing
    ----
     
    niam is an unknown quantity at this point niam's Avatar
    Join Date
    Jul 2012
    Posts
    1
    Accrued Payments
    0 USD (What is this?)
    Thanks
    0
    Thanked 1 Time in 1 Post
    SubscribeSubscribe
    Subscribed: 0
    pertanyaannya kurang detail
    semua pair atau hanya pair tertentu

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

    lebih detail kali aja bisa lanjut

    Though trading on financial markets entails high risk, still it can generate extra income on condition that you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  5. User Say Thank:

    raden123 (01-14-2018)

  6. #3 Collapse Post
    Orang Asing
    ----
     
    alixcool is an unknown quantity at this point alixcool's Avatar
    Join Date
    Feb 2014
    Location
    Pekanbaru
    Posts
    6
    Accrued Payments
    1 USD (What is this?)
    Thanks
    0
    Thanked 3 Times in 2 Posts
    SubscribeSubscribe
    Subscribed: 0
    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

    Though trading on financial markets entails high risk, still it can generate extra income on condition that you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  7. 2 Users Say Thank:

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

  8. #4 Collapse Post
    Knuckle Gesit
    Mengintai
     
    inLuk has a brilliant future inLuk has a brilliant future inLuk has a brilliant future inLuk has a brilliant future inLuk has a brilliant future inLuk has a brilliant future inLuk has a brilliant future inLuk has a brilliant future inLuk has a brilliant future inLuk has a brilliant future inLuk has a brilliant future inLuk's Avatar
    Join Date
    Apr 2017
    Location
    Indonesia
    Posts
    1,111
    Accrued Payments
    1558 USD (What is this?)
    Thanks
    1,152
    Thanked 1,587 Times in 605 Posts
    SubscribeSubscribe
    Subscribed: 0
    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 }
    
    
    }
    -- Telegram @inLuk --
    kunjungi thread saya:

  9. 3 Users Say Thank:

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

  10. #5 Collapse Post
    Banned
    ----
     
    raden123 has a reputation beyond repute raden123 has a reputation beyond repute raden123 has a reputation beyond repute raden123 has a reputation beyond repute raden123 has a reputation beyond repute raden123 has a reputation beyond repute raden123 has a reputation beyond repute raden123 has a reputation beyond repute raden123 has a reputation beyond repute raden123 has a reputation beyond repute raden123 has a reputation beyond repute raden123's Avatar
    Join Date
    Jan 2018
    Posts
    1,082
    Accrued Payments
    765 USD (What is this?)
    Thanks
    2,979
    Thanked 2,400 Times in 811 Posts
    SubscribeSubscribe
    Subscribed: 0
    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

    Though trading on financial markets entails high risk, still it can generate extra income on condition that you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  11. User Say Thank:


  12. #6 Collapse Post
    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,024
    Accrued Payments
    495 USD (What is this?)
    Thanks
    1,840
    Thanked 552 Times in 439 Posts
    SubscribeSubscribe
    Subscribed: 0
    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. 6 Users Say Thank:

    auto70 (07-21-2020), Unregistered (2)

Please read recommendations on how to write popular and useful posts in the Contest of the Best Answers Please read recommendations on how to write popular and useful posts in the Best Content Contest

Posting Permissions

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