web statistics

Bagian 8 - Menyusun EA

Discussion in 'Tutorial MQL4' started by white_tiger, Oct 20, 2008.

  1. chandrawg

    chandrawg
    Expand Collapse
    Moderator

    Joined:
    Aug 30, 2008
    Messages:
    577
    Likes Received:
    2
    Code:
    if (TimeHour(CurTime())>=18)
       {
       for (int i=0;i<OrdersTotal();i++)
          {
          if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
             {
             OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3);
             }
          }
       }
    
     
  2. krisdinus

    krisdinus
    Expand Collapse
    New Member

    Joined:
    Aug 11, 2009
    Messages:
    5
    Likes Received:
    0
    Membatasi jumlah buy dan sell

    Wah.. codenya mantabs.. begitu dicoba langsung jalan.. salut..
    minta tolong lagi donk, dibikinin code untuk membatasi jumlah order buy dan sell tiap harinya. misalnya hari ini maksimal bikin order buy 2 aja, dan order sell 3 aja, besok begitu lagi, maksimal order buy 2 aja, dan order sell 3. dst...
    terimakasih banyak loh bang Chandrawg...
     
  3. chandrawg

    chandrawg
    Expand Collapse
    Moderator

    Joined:
    Aug 30, 2008
    Messages:
    577
    Likes Received:
    2
    ea nya selalu cuma satu order (tunggu close dulu baru order lagi) ? atau selalu order banyak bersamaan ?
     
  4. krisdinus

    krisdinus
    Expand Collapse
    New Member

    Joined:
    Aug 11, 2009
    Messages:
    5
    Likes Received:
    0
    Eanya cuma satu order..
    makasi.. :)
     
    #114 krisdinus, Oct 7, 2009
    Last edited: Oct 7, 2009
  5. krisdinus

    krisdinus
    Expand Collapse
    New Member

    Joined:
    Aug 11, 2009
    Messages:
    5
    Likes Received:
    0
    iOpen

    Mau nanya..
    misal mau order jika harga open 1 bar sebelumnya lebih besar dari harga open 5 bar sebelumnya. kodenya gimana?
    if (iOpen(Symbol(),0,5) < iOpen(Symbol(),0,1))???

    Trims..
     
  6. chandrawg

    chandrawg
    Expand Collapse
    Moderator

    Joined:
    Aug 30, 2008
    Messages:
    577
    Likes Received:
    2
    iya dah benar codenya
     
  7. krisdinus

    krisdinus
    Expand Collapse
    New Member

    Joined:
    Aug 11, 2009
    Messages:
    5
    Likes Received:
    0
    Trus code untuk membatasi jumlah order buy dan sell tiap harinya. misalnya hari ini maksimal bikin order buy 2 aja, dan order sell 3 aja, besok begitu lagi, maksimal order buy 2 aja, dan order sell 3. dst...
    ea nya selalu cuma satu order (tunggu close dulu baru order lagi).
    terimakasih..:D
     
  8. chandrawg

    chandrawg
    Expand Collapse
    Moderator

    Joined:
    Aug 30, 2008
    Messages:
    577
    Likes Received:
    2
    codenya kurang lebih seperti ini
    Code:
    if ((totalbuy()>=2)||(totalsell()>=3)) return (0);
    int totalbuy()
    {
    int value=0;
    for (int i=0;i<10;i++)
       {
       if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
          {
          if ((OrderType()==0)&&(TimeDayOfYear(OrderOpenTime())==TimeDayOfYear(CurTime()))) value+=value;
          }
       }
    return (value);
    }
    
    int totalsell()
    {
    int value=0;
    for (int i=0;i<10;i++)
       {
       if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
          {
          if ((OrderType()==1)&&(TimeDayOfYear(OrderOpenTime())==TimeDayOfYear(CurTime()))) value+=value;
          }
       }
    return (value);
    }
    
     
  9. ir4fan

    ir4fan
    Expand Collapse
    New Member

    Joined:
    Jul 8, 2009
    Messages:
    34
    Likes Received:
    0
    bro tolong dong....
    gimana caranya supaya close op jika candlenya sudah berganti baru profit gak profit di close.....~x( ~x( ~x(

    di coba pake open[1] gak ngaruh....:p

    tolong bro...... :D :D :D
     
  10. chandrawg

    chandrawg
    Expand Collapse
    Moderator

    Joined:
    Aug 30, 2008
    Messages:
    577
    Likes Received:
    2
    Kayak gini kali :-"
    Code:
    datetime old_time; 
    if ( Time[0] != old_time )
    {
    for (int i;i<OrdersTotal();i++)
       {
       if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
          {
          OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3);
          }
       }
    old_time=Time[0];
    }
    
     

Share This Page