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

Tutorial Belajar coding / memasukkan indi custom

Discussion in 'Belajar MQL dari Nol' started by susanto, 23 Apr 2015.

  1. zega-fx

    zega-fx Member Credit Hunter

    Equity
    Credit
    Ref Point
    tolong pencerahan.. stiap kali buat perintah selalu ada error seperti di gambar.. dimana letak kesalahan ya masta? Screenshot - 8_13_2015 , 3_02_01 PM.png
     
  2. Abi Manyu

    Abi Manyu Member Credit Hunter

    Equity
    Credit
    Ref Point
    pertanyaan ane sama nih gan, kaga ada yang muncul di data window tapi menggambar garis. caranya gmn gan untuk bisa diinput modenya...? ini indikatornya mungkin bisa di bantu explore
     

    Attached Files:

  3. begalFX

    begalFX Member

    Equity
    Credit
    Ref Point
    ini termasuk bahasa pemrograman apa ya pak?
    pengen belajar
     
  4. Edy Gorbacev

    Edy Gorbacev Member Credit Hunter

    Equity
    Credit
    Ref Point
    Belajar native nya pake C++
     
  5. mahoo bar

    mahoo bar Member Credit Hunter

    Equity
    Credit
    Ref Point
  6. begalFX

    begalFX Member

    Equity
    Credit
    Ref Point
    terima kasih mas
    ijin belajar
     
  7. to2k mestizo

    to2k mestizo Member

    Equity
    Credit
    Ref Point
    ane siap belajar mastah, mohon arahannya :)
     
  8. mahoo bar

    mahoo bar Member Credit Hunter

    Equity
    Credit
    Ref Point
    jangan cuma siap gan, langsung daftar aja :D
     
  9. Trancexe

    Trancexe Active Member Credit Hunter

    Equity
    Credit
    Ref Point
    maaf mau tanya. ini kan ada idie custom.

    nah inoputan hanya ada step back.,

    saya ingin mengambil value indie ini untuk membuat Pendng Buy dan Pending sell..

    mohon pencerahan bagaimana menerjemahkan indi ini biar bisa di pakai sebagai acuan pending order

    Code:
    //+------------------------------------------------------------------+
    //|                                                  Daily range.mq4 |
    //|                                                         mishanya |
    //|                                           www.fxtradercenter.com |
    //+------------------------------------------------------------------+
    #property copyright "mishanya"
    #property link      "www.fxtradercenter.com"
    #property indicator_chart_window
    //----
    extern int StepBack=0;
    //----
    double X,rates_d1[][6],sup,res;
    int timeshift=0, timeshifts=0, beginner=0,d;
    int periods;
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //+------------------------------------------------------------------+
    int init()
      {
    //---- indicators
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    //| Custor indicator deinitialization function                       |
    //+------------------------------------------------------------------+
    int deinit()
      {
    //---- TODO: add your code here
       ObjectDelete("DSup line");
       ObjectDelete("DRes line");
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    //| Custom indicator iteration function                              |
    //+------------------------------------------------------------------+
    int start()
      {
       int    counted_bars=IndicatorCounted();
    //---- TODO: add your code here
       d=1+StepBack;
       switch(Period())
         {
          case PERIOD_M1:  {timeshifts=60; beginner=Hour()*60;} break;
          case PERIOD_M5:  {timeshifts=300; beginner=Hour()*12;} break;
          case PERIOD_M15: {timeshifts=900; beginner=Hour()*4;} break;
          case PERIOD_M30: {timeshifts=1800; beginner=Hour()*2;} break;
          case PERIOD_H1:  {timeshifts=3600; beginner=Hour()*1;} break;
          case PERIOD_H4:  {timeshifts=14400; beginner=Hour()*0.25;} break;
          case PERIOD_D1:  {timeshifts=86400; beginner=Hour()*0;} break;
         }
       timeshift=timeshifts*24;
    //----
       if(Period() > 86400)
         {
          Print("Error - Chart period is greater than 1 day.");
          return(-1); // then exit
         }
       ArrayCopyRates(rates_d1, Symbol(), PERIOD_D1);
    //---- 
       if (rates_d1[d][4]<rates_d1[d][1]) X=(rates_d1[d][3]+rates_d1[d][2]+rates_d1[d][4]+rates_d1[d][2])/2;
       if (rates_d1[d][4]>rates_d1[d][1]) X=(rates_d1[d][3]+rates_d1[d][2]+rates_d1[d][4]+rates_d1[d][3])/2;
       if (rates_d1[d][4]==rates_d1[d][1]) X=(rates_d1[d][3]+rates_d1[d][2]+rates_d1[d][4]+rates_d1[d][4])/2;
    //----
       sup=X - rates_d1[d][3];
       res=X - rates_d1[d][2];
       if (ObjectFind("DRes Line")!=0)
         {
          ObjectCreate("DRes line",OBJ_HLINE,0,Time[0],res);
          ObjectSet("DRes line",OBJPROP_COLOR,Red);
          ObjectSet("DRes line",OBJPROP_WIDTH,2);
         }
       else
         {
          ObjectMove("DRes line", 0,Time[0],res);
         }
       if (ObjectFind("DSup Line")!=0)
         {
          ObjectCreate("DSup line",OBJ_HLINE,0,Time[0],sup);
          ObjectSet("DSup line",OBJPROP_COLOR,Red);
          ObjectSet("DSup line",OBJPROP_WIDTH,2);
         }
       else
         {
          ObjectMove("DSup line", 0,Time[0],sup);
         }
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    //+------------------------------------------------------------------+
    //|                                                  Daily range.mq4 |
    //|                                                         mishanya |
    //|                                           www.fxtradercenter.com |
    //+------------------------------------------------------------------+
    #property copyright "mishanya"
    #property link      "www.fxtradercenter.com"
    #property indicator_chart_window
    //----
    extern int StepBack=0;
    //----
    double X,rates_d1[][6],sup,res;
    int timeshift=0, timeshifts=0, beginner=0,d;
    int periods;
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //+------------------------------------------------------------------+
    int init()
      {
    //---- indicators
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    //| Custor indicator deinitialization function                       |
    //+------------------------------------------------------------------+
    int deinit()
      {
    //---- TODO: add your code here
       ObjectDelete("DSup line");
       ObjectDelete("DRes line");
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    //| Custom indicator iteration function                              |
    //+------------------------------------------------------------------+
    int start()
      {
       int    counted_bars=IndicatorCounted();
    //---- TODO: add your code here
       d=1+StepBack;
       switch(Period())
         {
          case PERIOD_M1:  {timeshifts=60; beginner=Hour()*60;} break;
          case PERIOD_M5:  {timeshifts=300; beginner=Hour()*12;} break;
          case PERIOD_M15: {timeshifts=900; beginner=Hour()*4;} break;
          case PERIOD_M30: {timeshifts=1800; beginner=Hour()*2;} break;
          case PERIOD_H1:  {timeshifts=3600; beginner=Hour()*1;} break;
          case PERIOD_H4:  {timeshifts=14400; beginner=Hour()*0.25;} break;
          case PERIOD_D1:  {timeshifts=86400; beginner=Hour()*0;} break;
         }
       timeshift=timeshifts*24;
    //----
       if(Period() > 86400)
         {
          Print("Error - Chart period is greater than 1 day.");
          return(-1); // then exit
         }
       ArrayCopyRates(rates_d1, Symbol(), PERIOD_D1);
    //---- 
       if (rates_d1[d][4]<rates_d1[d][1]) X=(rates_d1[d][3]+rates_d1[d][2]+rates_d1[d][4]+rates_d1[d][2])/2;
       if (rates_d1[d][4]>rates_d1[d][1]) X=(rates_d1[d][3]+rates_d1[d][2]+rates_d1[d][4]+rates_d1[d][3])/2;
       if (rates_d1[d][4]==rates_d1[d][1]) X=(rates_d1[d][3]+rates_d1[d][2]+rates_d1[d][4]+rates_d1[d][4])/2;
    //----
       sup=X - rates_d1[d][3];
       res=X - rates_d1[d][2];
       if (ObjectFind("DRes Line")!=0)
         {
          ObjectCreate("DRes line",OBJ_HLINE,0,Time[0],res);
          ObjectSet("DRes line",OBJPROP_COLOR,Red);
          ObjectSet("DRes line",OBJPROP_WIDTH,2);
         }
       else
         {
          ObjectMove("DRes line", 0,Time[0],res);
         }
       if (ObjectFind("DSup Line")!=0)
         {
          ObjectCreate("DSup line",OBJ_HLINE,0,Time[0],sup);
          ObjectSet("DSup line",OBJPROP_COLOR,Red);
          ObjectSet("DSup line",OBJPROP_WIDTH,2);
         }
       else
         {
          ObjectMove("DSup line", 0,Time[0],sup);
         }
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
     
  10. ltsbahar99

    ltsbahar99 New Member

    Equity
    Credit
    Ref Point
    masta gimana cara codingnya kalo menggunakan indi ini???
     

    Attached Files:

  11. ltsbahar99

    ltsbahar99 New Member

    Equity
    Credit
    Ref Point
    mohon petunjuknya masta, kira-kira apa yng salah kok tdak mau op di >90 dan <5

    /*-- Parameter ini ditampilkan di EA dan bisa diubah --*/
    extern int TakeProfit = 15; // Nilai TP setiap OP di EA Martingale ini
    extern int PipStep = 10; // Jarak pip dimana akan buka OP baru
    extern int Slippage = 3; // Apa itu slippage ? Googling sendiri ya..
    extern double Lots = 0.01; // Nilai lots awal, nantinya akan digandakan setiap step
    extern double Multiply = 2.0; // Nilai pengali setiap step OP baru
    extern int MaxTrade = 11; // Banyak OP maksimal yang boleh dijalankan
    extern bool UseTime = TRUE; // Pilihan apakah memakai waktu bekerjanya EA ?
    extern int HourStart = 0; // Waktu mulai EA bekerja
    extern int HourEnd = 24; // Waktu akhir EA bekerja
    extern int Len = 7;
    extern double Filter = 0.0;





    /*-- Parameter ini tidak ditampilkan di EA --*/
    string EAName = " BISMILLAH_99"; // Nama EA, untuk ditampilkan di layar
    string EAComment = "baharfx"; // Variabel ini akan kita masukkan di setiap OP sebagai Comment
    int EAMagicNumber = 12345; // Magic Number
    double SetPoint = 0; // Variabel SetPoint untuk kode digit broker 4 atau 5


    //+------------------------------------------------------------------+
    //| expert initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //----

    SetBroker();

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

    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert start function |
    //+------------------------------------------------------------------+
    int start()
    {
    //----
    int iTrade=0;


    Comment(EAName); // Tampilkan Nama EA di layar

    /* -- Jika tidak ada OP sama sekali, maka jalankan fungsi berikut --*/
    /* -- Disinilah tempat anda memasukkan koding indikator untuk memicu OP --*/
    if(OrdersTotal()==0)
    {
    if((UseTime) && (Hour() >= HourStart && Hour() <= HourEnd))
    if (iCustom(Symbol(),0,"MBFX Timing",Len,Filter,0,1,0) >=93)
    {

    OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, Bid-TakeProfit*SetPoint, EAComment, EAMagicNumber);


    }
    else if((iCustom(Symbol(),0,"MBFX Timing",Len,Filter,0,2,0) <=5))
    {

    OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, Ask+TakeProfit*SetPoint, EAComment, EAMagicNumber);
    }

    }


    /* -- Inilah Fungsi Martingale. Jika ada OP yang salah, maka lakukan martingale --*/
    if(OrdersTotal()>=1)
    {
    GoMartingale();
    }


    //----
    return(0);
    }
    //+------------------------------------------------------------------+

    /*--agar EA bisa running di Broker 4 Digit atau 5 Digit--*/
    void SetBroker()
    {
    if (Digits==3 || Digits==5) // Perintah untuk broker 5 Digits
    {SetPoint=Point*10;}
    else // Perintah untuk broker 4 Digits
    {SetPoint=Point;}
    }

    void GoMartingale()
    {
    int iCount = 0;
    double LastOP = 0;
    double LastLots = 0;
    bool LastIsBuy = FALSE;
    int iTotalBuy = 0;
    int iTotalSell = 0;
    int Spread=0;

    Spread= MarketInfo(Symbol(), MODE_SPREAD);


    for(iCount=0;iCount<OrdersTotal();iCount++)
    {

    OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES);

    if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
    {
    if(LastOP==0) {LastOP=OrderOpenPrice();}
    if(LastOP>OrderOpenPrice()) {LastOP=OrderOpenPrice();}
    if(LastLots<OrderLots()) {LastLots=OrderLots();}
    LastIsBuy=TRUE;
    iTotalBuy++;

    /* Bila mencapai batas OP maksimal, jangan tambah OP lagi */
    if(iTotalBuy==MaxTrade) {return(0);}
    }

    if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
    {
    if(LastOP==0) {LastOP=OrderOpenPrice();}
    if(LastOP<OrderOpenPrice()) {LastOP=OrderOpenPrice();}
    if(LastLots<OrderLots()) {LastLots=OrderLots();}
    LastIsBuy=FALSE;
    iTotalSell++;

    /* Bila mencapai batas OP maksimal, jangan tambah OP lagi */
    if(iTotalBuy==MaxTrade) {return(0);}
    }

    }

    /* Jika arah Price adalah DOWNTREND...., Periksa nilai Bid (*/
    if(LastIsBuy)
    {
    if(Bid<=LastOP-(Spread*SetPoint)-(PipStep*SetPoint))
    {
    OrderSend(Symbol(), OP_BUY, Multiply*LastLots, Ask, Slippage, 0, Ask+TakeProfit*SetPoint, EAComment, EAMagicNumber);
    ModifyTP();
    LastIsBuy=FALSE;
    return(0);
    }
    }
    /* Jika arah Price adalah Sell...., Periksa nilai Ask (*/
    else if(!LastIsBuy)
    {
    if(Ask>=LastOP+(Spread*SetPoint)+(PipStep*SetPoint))
    {
    OrderSend(Symbol(), OP_SELL, Multiply*LastLots, Bid, Slippage, 0, Bid-TakeProfit*SetPoint, EAComment, EAMagicNumber);
    ModifyTP();
    return(0);
    }
    }

    }

    /*-- Fungsi ModifyTP ini untuk mengubah semua OP agar TP di titik yang sama --*/
    void ModifyTP()
    {
    int iCount=0;
    double NewTP=0;

    /*- Ambil nilai Take Profit dari Order terakhir -*/
    for(iCount=0;iCount<OrdersTotal();iCount++)
    {

    OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES);

    /*-- Kalau OP-nya adalah BUY, ambil nilai TP yang paling kecil. Jadikan TP bersama --*/
    if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
    {
    if(NewTP==0) {NewTP=OrderTakeProfit();}
    if(NewTP>OrderTakeProfit()) {NewTP=OrderTakeProfit();}

    }

    /*-- Kalau OP-nya adalah SELL, ambil nilai TP yang paling besar. Jadikan TP bersama --*/
    if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
    {
    if(NewTP==0) {NewTP=OrderTakeProfit();}
    if(NewTP<OrderTakeProfit()) {NewTP=OrderTakeProfit();}
    }

    }

    /*- Ubah semua nilai OP TakeProfit dengan yang baru (2x lipat) -*/
    for(iCount=0;iCount<OrdersTotal();iCount++)
    {

    OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES);

    /*- Kalau semua OP adalah BUY, maka ubahlah TP mereka -*/
    if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
    {
    OrderModify(OrderTicket(), OrderLots(), 0, NewTP, 0);
    }

    /*- Kalau semua OP adalah SELL, maka ubahlah TP mereka -*/
    if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
    {
    OrderModify(OrderTicket(), OrderLots(), 0, NewTP, 0);
    }

    }
    }
     
  12. antojoel

    antojoel New Member Credit Hunter

    Equity
    Credit
    Ref Point
    terimakasih sharing icustom.. sangat membantu..:ok::h:
     
  13. tijawe

    tijawe New Member

    Equity
    Credit
    Ref Point
    how to create a language program for indicators of envelopes along with input parameters
    if the price pass / exceed the blue line (upper band) then open Buy
    if the price pass / exceed the red line (lower band) then open Sell
     

    Attached Files:

    • Dislike Dislike x 1
  14. ag5181

    ag5181 New Member

    Equity
    Credit
    Ref Point
    ijin belajar :)
     

Share This Page