1. Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)
    Dismiss Notice

Suggestion Fungsi Order baru jika TP atau SL

Discussion in 'Belajar MQL dari Nol' started by Andri_Susilo, 08 Aug 2016.

  1. Andri_Susilo

    Andri_Susilo Member Credit Hunter

    Equity
    Credit
    Ref Point
    Saya mencoba membuat EA BUY dan SEll bersamaan dengan TP dan SL. Nah yang ingin saya tanyakan buat master koding disini.... bagaimana membuat perintah baru jika OP BUY terkena TP maka buka order baru dengan penambahan lot, tapi jika terkena SL maka membuka order baru dengan lot yang dikurangi. demikian juga dengan kondisi OP sell nya.

    dibawah sy sertakan EA buysell saya. Mudah mudahan yang menjawab bisa WD tiap hari hehe ;););)
     

    Attached Files:

  2. NeoBatavia

    NeoBatavia Well-Known Member Credit Hunter

    Equity
    Credit
    Ref Point
    Ikut nunggu para master programmer.
     
  3. Andri_Susilo

    Andri_Susilo Member Credit Hunter

    Equity
    Credit
    Ref Point
    hehe master codingnya lgi liburan ke singapore kaleee...:D:D:D:D
     
  4. Trancexe

    Trancexe Active Member Credit Hunter

    Equity
    Credit
    Ref Point
    membaca nilai OrderClosePrice apakah sama dengan OrderStopLoss dan OrderTakeProfit..
    penasaran jga.. coba ah
     
  5. Andri_Susilo

    Andri_Susilo Member Credit Hunter

    Equity
    Credit
    Ref Point
    hehehe si master ini mancing2 mulu,...hehehe mumet kepala g berhasil.
     
  6. Trancexe

    Trancexe Active Member Credit Hunter

    Equity
    Credit
    Ref Point
    di int start tambahkan
    Code:
      if(jumlahorder(0)==0 && jumlahorder(1) == 0 && Lanjut)
        {
         lanjutop();
        }
    setelah int start
    Code:
    void lanjutop() {
       for (int count = 0; count < OrdersHistoryTotal(); count++) {
          if (OrderSelect(count, SELECT_BY_POS, MODE_HISTORY))
          {
             if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
               {
                //catat nilai lot terakhir
                if(LastLotSize==0) {LastLotSize=OrderLots();}
                else if(LastLotSize<OrderLots()) {LastLotSize=OrderLots();}
                //Jika Lot Size leih besar dari max lot
                if(LastLotSize>MaxLot){LastLotSize=MaxLot;} 
                //Catat Apakah Ea terkena SL/TP dan tentukan Lot
                if(OrderClosePrice()==OrderStopLoss()){LastLotSize=NormalizeDouble(LastLotSize*Multiply,2);}
                else if(OrderClosePrice()==OrderTakeProfit()){LastLotSize=NormalizeDouble(LastLotSize/Multiply,2);}           
               }
              if(jumlahorder(0)==0 && OrderType()==OP_BUY)
                {
                 iTicket=OrderSend(Symbol(),OP_BUY,LastLotSize,Ask,3,Ask-SL*Point,Ask+TP*Point,Nama_EA,Magic,0,Green);Sleep(1000);
                }
              else if(jumlahorder(1)==0 && OrderType()==OP_SELL)
                     {
                      iTicket=OrderSend(Symbol(),OP_SELL,LastLotSize,Bid,3,Bid+SL*Point,Bid-TP*Point,Nama_EA,Magic,Red);Sleep(1000);
                     }
          }
         
          }
       }
       
    
    blm tau work apa ga.. soalnya di mt4 ane kena order Send error 130 terus..
     
    • Like Like x 1
  7. Andri_Susilo

    Andri_Susilo Member Credit Hunter

    Equity
    Credit
    Ref Point
    tak coba dulu gan... btw makasih buanyak sdh kasih pencerahan. semoga bayak rejekinya
     
  8. Andri_Susilo

    Andri_Susilo Member Credit Hunter

    Equity
    Credit
    Ref Point
    extern int Magic = 212;
    extern string EACom = "Andri";
    extern int Slippage = 3;
    extern double Lots = 0.10;
    extern int TakeProfit = 10;
    extern int StopLoss = 10;
    extern string Pair ="";

    string Sym;

    //+------------------------------------------------------------------+
    //| expert initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //----
    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert deinitialization function |
    //+------------------------------------------------------------------+
    int deinit()
    {
    //----
    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert start function |
    //+------------------------------------------------------------------+
    int start()
    {
    //----


    if(OrdersTotal()==0)
    {
    OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point, Ask+TakeProfit*Point,EACom,Magic,0,Blue);
    OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point, Bid-TakeProfit*Point,EACom,Magic,0,Red);
    }
    if(jumlahorder(0)==0 && jumlahorder(1) == 0 && Lanjut)
    {
    lanjutop();
    }
    return(0);
    }
    //+------------------------------------------------------------------+


    int jumlahorder( int tipe)
    {
    int total=0;
    for(int i=0; i<OrdersTotal(); i++)
    {
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()!=tipe) continue;
    total++;
    }

    return(total);
    }

    void lanjutop() {
    for (int count = 0; count < OrdersHistoryTotal(); count++) {
    if (OrderSelect(count, SELECT_BY_POS, MODE_HISTORY))
    {
    if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
    {
    //catat nilai lot terakhir
    if(LastLotSize==0) {LastLotSize=OrderLots();}
    else if(LastLotSize<OrderLots()) {LastLotSize=OrderLots();}
    //Jika Lot Size leih besar dari max lot
    if(LastLotSize>MaxLot){LastLotSize=MaxLot;}
    //Catat Apakah Ea terkena SL/TP dan tentukan Lot
    if(OrderClosePrice()==OrderStopLoss()){LastLotSize=NormalizeDouble(LastLotSize*Multiply,2);}
    else if(OrderClosePrice()==OrderTakeProfit()){LastLotSize=NormalizeDouble(LastLotSize/Multiply,2);}
    }
    if(jumlahorder(0)==0 && OrderType()==OP_BUY)
    {
    iTicket=OrderSend(Symbol(),OP_BUY,LastLotSize,Ask,3,Ask-SL*Point,Ask+TP*Point,Nama_EA,Magic,0,Green);Sleep(1000);
    }
    else if(jumlahorder(1)==0 && OrderType()==OP_SELL)
    {
    iTicket=OrderSend(Symbol(),OP_SELL,LastLotSize,Bid,3,Bid+SL*Point,Bid-TP*Point,Nama_EA,Magic,Red);Sleep(1000);
    }
    }

    }
    }
     
  9. Andri_Susilo

    Andri_Susilo Member Credit Hunter

    Equity
    Credit
    Ref Point
    error master
    :(:(:(
     
  10. Andri_Susilo

    Andri_Susilo Member Credit Hunter

    Equity
    Credit
    Ref Point
    deklarasi Lanjut gmn master ???
     

    Attached Files:

  11. Trancexe

    Trancexe Active Member Credit Hunter

    Equity
    Credit
    Ref Point
    di extern bikin

    bool lanjut = true;

    trus bikin variable global

    double LastLotSize = 0;

    cuma saya mikir..
    bsa jdi void lanjutop() ga tereksekusi, karena ketika order jadi 0, kemungkinan yang di eksekusi yang order send paling atas..

    alternatif.. langsung jalankan void.
    tpi saya blm test bugnya dmn.

    kita coba diskusi aja. siapa tau ntr ada master2 yang mampir. maklum lah gan ane juga belajarnya otodidak. basicnya ekonomi bukan dari kampus IT
     

Share This Page