• 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 :)

Tutorial BELAJAR MQL4 SAMPAI MAHIR

zega-fx

Member
Credit Hunter
Credits
0
salam...
ini saya COPAS dari sebuah artikel teman trader kita pada blognya..
jujur saja ni ya, sudah berapa kali saya membaca artikel ini tapi belum juga bisa menciptakan sebuah EA, pasti ada saja ERRORnya..
saya buat Thread ini berharap ada para masta masti share script2 jitu nya di sini, hehehe..
salam trader..
:horree::horree::horree:
 

Attachments

Last edited:
Ayo sekarang kita belajar buat EA menggunakan Price Action, strategi/metode apalagi itu??? metode deteksi harga tanpa indikator dengan pola sederhana maupun kompleks dengan tambahan unsur lain (tingkat fibo, support dan resistance dll) silahkan tambahkan sendiri

Strategi / Metode
Inside Bar/ Di dalam Bar adalah bar yang memiliki tubuh dan sumbu terkandung sepenuhnya dalam kisaran sebelumnya (ibu) bar. Tinggi dalam bar terletak lebih rendah dan rendah terletak lebih tinggi dari yang ibu bar. Ibu dan di dalam bar membentuk pola dianggap sinyal potensial entri.

Ini adalah pola dua sisi, karena mungkin menunjukkan baik pembalikan, atau kelanjutan tren.
untuk lebih jelasnya silakan lihat gambar berikut:
Fig5_price_action_inside_bar_sellstop__1.png

Fig2_inbar_shema__1.png

Aturan yang dipakai :
  • Pola Inside Bar lebih baik digunakan pada jangka waktu yang lebih tinggi, seperti H4 atau D1.
  • Pola dapat menunjukkan baik pembalikan tren atau kelanjutan.
  • Terapkan tambahan alat analisis grafis untuk entri yang lebih tepat, termasuk garis tren, tingkat support / resistance, level Fibo, pola Harga Aksi lainnya, dll
  • Gunakan pending order untuk menghindari entri pasar prematur atau salah.
  • Jangan gunakan Inside Bar/dalam bar berulang kali terjadi di pasar datar sebagai sinyal masuk pasar.
Fig3_price_action_inside_bar1__2.png

Cara masuk pasarnya bagaimana?????

begini nich
Fig4_price_action_inside_bar_buystop__1.png

 
Sekarang bagaimana menterjemahkan dalam bahasa MQL agar bisa dipake di dalam EA

Code:
//+------------------------------------------------------------------+
//|                                                Price Action.mq4 |
//|                                                          ngasqus |
//|                                              https://soehoe.com |
//+------------------------------------------------------------------+
#property copyright "ngasqus"
#property link      "https://soehoe.com"
#property version  "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                            |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+

yang di atas adalah EA kosong masih belum di apa-apain, belum di isi dengan strategi price action

Kita perlu definisikan candle di dalam setelah candle ditutup untuk itu diperlukan variable baru untuk menetapkan nilai-nilai mereka ntar jadinya seperti ini :
Code:
//+------------------------------------------------------------------+
//|                                                Price Action.mq4 |
//|                                                          ngasqus |
//|                                              https://soehoe.com |
//+------------------------------------------------------------------+
#property copyright "ngasqus"
#property link      "https://soehoe.com"
#property version  "1.00"
#property strict

double  open1,//candle pertama Open price
open2,    //candle kedua Open price
close1,  //candle pertama Close price
close2,  //candle kedua Close price
low1,    //candle pertama Low price
low2,    //candle kedua Low price
high1,    //candle pertama High price
high2;    //candle kedua High price
//+------------------------------------------------------------------+
//| Expert initialization function                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                            |
//+------------------------------------------------------------------+
void OnTick()
  {
//-Menentukan harga dari candle yang diperlukan-
  open1        = NormalizeDouble(iOpen(Symbol(), Period(), 1), Digits);
  open2        = NormalizeDouble(iOpen(Symbol(), Period(), 2), Digits);
  close1      = NormalizeDouble(iClose(Symbol(), Period(), 1), Digits);
  close2      = NormalizeDouble(iClose(Symbol(), Period(), 2), Digits);
  low1        = NormalizeDouble(iLow(Symbol(), Period(), 1), Digits);
  low2        = NormalizeDouble(iLow(Symbol(), Period(), 2), Digits);
  high1        = NormalizeDouble(iHigh(Symbol(), Period(), 1), Digits);
  high2        = NormalizeDouble(iHigh(Symbol(), Period(), 2), Digits);
  }
//+------------------------------------------------------------------+

sebagai contoh, jika candle pertama bearish (candle 2) sedangkan inside barnya bullish (candle 1) mari ditambahkan ke dalam kode fungsi OnTick

Code:
 if(open2>close2 && //candle ke 2 is bullish
      close1>open1 && //candle  is bearish
      high2>high1 &&  //the bar 2 High exceeds the first one's High
      open2>close1 && //the second bar's Open exceeds the first bar's Close
      low2<low1)      //the second bar's Low is lower than the first bar's Low

O iya belum ditambahkan variable lainnya
Code:
extern int    interval          = 20;                              //Interval
extern double  lot              = 0.1;                              //Lot Size
extern int    TP                = 300;                              //Take Profit
extern int    magic            = 555124;                          //Magic number
extern int    slippage          = 2;                                //Slippage
extern int    ExpDate          = 48;                              //Expiration Hour Order
extern int    bar2size          = 800;                              //Bar 2 Size
 
fungsi koreksi kesalahan
Code:
//+----------------------------------------------------------------------------------------------------------------------+
//| The function opens or sets an order                                                                                  |
//| symbol      - simbol dimana order dilakukan                                                                          |
//| cmd        - order                                                                                                  |
//| volume      - jumlah lots                                                                                            |
//| price      - buka harga                                                                                            |
//| slippage    -                                                                                                        |
//| stoploss    -                                                                                                        |
//| takeprofit  -                                                                                                        |
//| comment    -                                                                                                        |
//| magic      -                                                                                                        |
//| expiration  -                                                                                                        |
//| arrow_color -                                                                                                        |
//+----------------------------------------------------------------------------------------------------------------------+
int OrderOpenF(string    OO_symbol,
              int        OO_cmd,
              double    OO_volume,
              double    OO_price,
              int        OO_slippage,
              double    OO_stoploss,
              double    OO_takeprofit,
              string    OO_comment,
              int        OO_magic,
              datetime  OO_expiration,
              color      OO_arrow_color)
  {
  int      result      = -1;    //result of opening an order
  int      Error      = 0;    //error when opening an order
  int      attempt    = 0;    //amount of performed attempts
  int      attemptMax  = 3;    //maximum amount of attempts
  bool    exit_loop  = false; //exit the loop
  string  lang=TerminalInfoString(TERMINAL_LANGUAGE);  //trading terminal language, for defining the language of the messages
  double  stopllvl=NormalizeDouble(MarketInfo(OO_symbol,MODE_STOPLEVEL)*MarketInfo(OO_symbol,MODE_POINT),Digits);  //minimum stop loss/ take profit level, in points
                                                                                                                    //the module provides safe order opening.
//--- check stop orders for buying
  if(OO_cmd==OP_BUY || OO_cmd==OP_BUYLIMIT || OO_cmd==OP_BUYSTOP)
    {
      double tp = (OO_takeprofit - OO_price)/MarketInfo(OO_symbol, MODE_POINT);
      double sl = (OO_price - OO_stoploss)/MarketInfo(OO_symbol, MODE_POINT);
      if(tp>0 && tp<=stopllvl)
        {
        OO_takeprofit=OO_price+stopllvl+2*MarketInfo(OO_symbol,MODE_POINT);
        }
      if(sl>0 && sl<=stopllvl)
        {
        OO_stoploss=OO_price -(stopllvl+2*MarketInfo(OO_symbol,MODE_POINT));
        }
    }
//--- check stop orders for selling
  if(OO_cmd==OP_SELL || OO_cmd==OP_SELLLIMIT || OO_cmd==OP_SELLSTOP)
    {
      double tp = (OO_price - OO_takeprofit)/MarketInfo(OO_symbol, MODE_POINT);
      double sl = (OO_stoploss - OO_price)/MarketInfo(OO_symbol, MODE_POINT);
      if(tp>0 && tp<=stopllvl)
        {
        OO_takeprofit=OO_price -(stopllvl+2*MarketInfo(OO_symbol,MODE_POINT));
        }
      if(sl>0 && sl<=stopllvl)
        {
        OO_stoploss=OO_price+stopllvl+2*MarketInfo(OO_symbol,MODE_POINT);
        }
    }
//--- while loop
  while(!exit_loop)
    {
      result=OrderSend(OO_symbol,OO_cmd,OO_volume,OO_price,OO_slippage,OO_stoploss,OO_takeprofit,OO_comment,OO_magic,OO_expiration,OO_arrow_color); //attempt to open an order using the specified parameters
      //--- if there is an error when opening an order
      if(result<0)
        {
        Error = GetLastError();                                    //assign a code to an error
        switch(Error)                                              //error enumeration
          {                                                        //order closing error enumeration and an attempt to fix them
            case  2:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(3000);                                      //3 seconds of delay
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt=0;                                        //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case  3:
              RefreshRates();
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case  4:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(3000);                                      //3 seconds of delay
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case  5:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case  6:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(5000);                                      //3 seconds of delay
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case  8:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(7000);                                      //3 seconds of delay
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 64:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case 65:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case 128:
              Sleep(3000);
              RefreshRates();
              continue;                                            //exit switch
            case 129:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(3000);                                      //3 seconds of delay
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 130:
              exit_loop=true;                                      //exit while
              break;
            case 131:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case 132:
              Sleep(10000);                                        //sleep for 10 seconds
              RefreshRates();                                      //update data
              //exit_loop = true;                                  //exit while
              break;                                                //exit switch
            case 133:
              exit_loop=true;                                      //exit while
              break;                                                //exit switch
            case 134:
              exit_loop=true;                                      //exit while
              break;                                                //exit switch
            case 135:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 136:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 137:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  Sleep(2000);
                  RefreshRates();
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 138:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  Sleep(1000);
                  RefreshRates();
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 139:
              exit_loop=true;
              break;
            case 141:
              Sleep(5000);
              exit_loop=true;
              break;
            case 145:
              exit_loop=true;
              break;
            case 146:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  Sleep(2000);
                  RefreshRates();
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 147:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  OO_expiration=0;
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 148:
              exit_loop=true;
              break;
            default:
              Print("Error: ",Error);
              exit_loop=true; //exit while
              break;          //other options
          }
        }
      //--- if no errors detected
      else
        {
        if(lang == "Indonesian") {Print("Order berhasil dilakukan. ", result);}
        if(lang == "English") {Print("The order is successfully opened.", result);}
        Error = 0;                                //reset the error code to zero
        break;                                    //exit while
        //errorCount =0;                          //reset the amount of attempts to zero
        }
    }
  return(result);

Mau masukin semua EA disini ternyata g cukup. Untuk selengkapnya silakan di download EAnya dan di BT sepuasnya, masih bisa dikoreksi ataupun ditambahkan strategi lain.
 

Attachments

saya coba BT tapi ga buka posisi mas. apa yang salah ya..?
 
mas ngasqus mau tanya dong, rumus mengambil data harga dari data history trading terakhir untuk coding? misalnya kita membuka posisi dengan SL dan TP, setelah harga kena SL maka untuk mengambil data harga tsbt untuk membuat entry harga sebelumnya +100 atau - 100point, bagaimana ya?

hehehe.. saya bukan programer.. ada sedikit logika terpendam ni...
 
ok mas, bantu ajarin ya.. :D
 
slamat pagi , saya mau bertanya bagaimana mendapatkan kuadrat math pow untuk menggandakan lot, seperti ini..
NormalizeDouble(StartLots * MathPow(LotsExponent,????)); saya tidak mengerti dengan yang ada pada tanda "????" itu, mohon pencerahan... bagaimana mengambil data tersebut ke dalam variable. trmkasih..
 
fungsi koreksi kesalahan
Code:
//+----------------------------------------------------------------------------------------------------------------------+
//| The function opens or sets an order                                                                                  |
//| symbol      - simbol dimana order dilakukan                                                                          |
//| cmd        - order                                                                                                  |
//| volume      - jumlah lots                                                                                            |
//| price      - buka harga                                                                                            |
//| slippage    -                                                                                                        |
//| stoploss    -                                                                                                        |
//| takeprofit  -                                                                                                        |
//| comment    -                                                                                                        |
//| magic      -                                                                                                        |
//| expiration  -                                                                                                        |
//| arrow_color -                                                                                                        |
//+----------------------------------------------------------------------------------------------------------------------+
int OrderOpenF(string    OO_symbol,
              int        OO_cmd,
              double    OO_volume,
              double    OO_price,
              int        OO_slippage,
              double    OO_stoploss,
              double    OO_takeprofit,
              string    OO_comment,
              int        OO_magic,
              datetime  OO_expiration,
              color      OO_arrow_color)
  {
  int      result      = -1;    //result of opening an order
  int      Error      = 0;    //error when opening an order
  int      attempt    = 0;    //amount of performed attempts
  int      attemptMax  = 3;    //maximum amount of attempts
  bool    exit_loop  = false; //exit the loop
  string  lang=TerminalInfoString(TERMINAL_LANGUAGE);  //trading terminal language, for defining the language of the messages
  double  stopllvl=NormalizeDouble(MarketInfo(OO_symbol,MODE_STOPLEVEL)*MarketInfo(OO_symbol,MODE_POINT),Digits);  //minimum stop loss/ take profit level, in points
                                                                                                                    //the module provides safe order opening.
//--- check stop orders for buying
  if(OO_cmd==OP_BUY || OO_cmd==OP_BUYLIMIT || OO_cmd==OP_BUYSTOP)
    {
      double tp = (OO_takeprofit - OO_price)/MarketInfo(OO_symbol, MODE_POINT);
      double sl = (OO_price - OO_stoploss)/MarketInfo(OO_symbol, MODE_POINT);
      if(tp>0 && tp<=stopllvl)
        {
        OO_takeprofit=OO_price+stopllvl+2*MarketInfo(OO_symbol,MODE_POINT);
        }
      if(sl>0 && sl<=stopllvl)
        {
        OO_stoploss=OO_price -(stopllvl+2*MarketInfo(OO_symbol,MODE_POINT));
        }
    }
//--- check stop orders for selling
  if(OO_cmd==OP_SELL || OO_cmd==OP_SELLLIMIT || OO_cmd==OP_SELLSTOP)
    {
      double tp = (OO_price - OO_takeprofit)/MarketInfo(OO_symbol, MODE_POINT);
      double sl = (OO_stoploss - OO_price)/MarketInfo(OO_symbol, MODE_POINT);
      if(tp>0 && tp<=stopllvl)
        {
        OO_takeprofit=OO_price -(stopllvl+2*MarketInfo(OO_symbol,MODE_POINT));
        }
      if(sl>0 && sl<=stopllvl)
        {
        OO_stoploss=OO_price+stopllvl+2*MarketInfo(OO_symbol,MODE_POINT);
        }
    }
//--- while loop
  while(!exit_loop)
    {
      result=OrderSend(OO_symbol,OO_cmd,OO_volume,OO_price,OO_slippage,OO_stoploss,OO_takeprofit,OO_comment,OO_magic,OO_expiration,OO_arrow_color); //attempt to open an order using the specified parameters
      //--- if there is an error when opening an order
      if(result<0)
        {
        Error = GetLastError();                                    //assign a code to an error
        switch(Error)                                              //error enumeration
          {                                                        //order closing error enumeration and an attempt to fix them
            case  2:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(3000);                                      //3 seconds of delay
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt=0;                                        //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case  3:
              RefreshRates();
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case  4:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(3000);                                      //3 seconds of delay
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case  5:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case  6:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(5000);                                      //3 seconds of delay
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case  8:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(7000);                                      //3 seconds of delay
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 64:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case 65:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case 128:
              Sleep(3000);
              RefreshRates();
              continue;                                            //exit switch
            case 129:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(3000);                                      //3 seconds of delay
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 130:
              exit_loop=true;                                      //exit while
              break;
            case 131:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case 132:
              Sleep(10000);                                        //sleep for 10 seconds
              RefreshRates();                                      //update data
              //exit_loop = true;                                  //exit while
              break;                                                //exit switch
            case 133:
              exit_loop=true;                                      //exit while
              break;                                                //exit switch
            case 134:
              exit_loop=true;                                      //exit while
              break;                                                //exit switch
            case 135:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 136:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 137:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  Sleep(2000);
                  RefreshRates();
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 138:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  Sleep(1000);
                  RefreshRates();
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 139:
              exit_loop=true;
              break;
            case 141:
              Sleep(5000);
              exit_loop=true;
              break;
            case 145:
              exit_loop=true;
              break;
            case 146:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  Sleep(2000);
                  RefreshRates();
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 147:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  OO_expiration=0;
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 148:
              exit_loop=true;
              break;
            default:
              Print("Error: ",Error);
              exit_loop=true; //exit while
              break;          //other options
          }
        }
      //--- if no errors detected
      else
        {
        if(lang == "Indonesian") {Print("Order berhasil dilakukan. ", result);}
        if(lang == "English") {Print("The order is successfully opened.", result);}
        Error = 0;                                //reset the error code to zero
        break;                                    //exit while
        //errorCount =0;                          //reset the amount of attempts to zero
        }
    }
  return(result);

Mau masukin semua EA disini ternyata g cukup. Untuk selengkapnya silakan di download EAnya dan di BT sepuasnya, masih bisa dikoreksi ataupun ditambahkan strategi lain.

gan, bisakah aq minta file mq4 ea yg bersistem marti
 
fungsi koreksi kesalahan
Code:
//+----------------------------------------------------------------------------------------------------------------------+
//| The function opens or sets an order                                                                                  |
//| symbol      - simbol dimana order dilakukan                                                                          |
//| cmd        - order                                                                                                  |
//| volume      - jumlah lots                                                                                            |
//| price      - buka harga                                                                                            |
//| slippage    -                                                                                                        |
//| stoploss    -                                                                                                        |
//| takeprofit  -                                                                                                        |
//| comment    -                                                                                                        |
//| magic      -                                                                                                        |
//| expiration  -                                                                                                        |
//| arrow_color -                                                                                                        |
//+----------------------------------------------------------------------------------------------------------------------+
int OrderOpenF(string    OO_symbol,
              int        OO_cmd,
              double    OO_volume,
              double    OO_price,
              int        OO_slippage,
              double    OO_stoploss,
              double    OO_takeprofit,
              string    OO_comment,
              int        OO_magic,
              datetime  OO_expiration,
              color      OO_arrow_color)
  {
  int      result      = -1;    //result of opening an order
  int      Error      = 0;    //error when opening an order
  int      attempt    = 0;    //amount of performed attempts
  int      attemptMax  = 3;    //maximum amount of attempts
  bool    exit_loop  = false; //exit the loop
  string  lang=TerminalInfoString(TERMINAL_LANGUAGE);  //trading terminal language, for defining the language of the messages
  double  stopllvl=NormalizeDouble(MarketInfo(OO_symbol,MODE_STOPLEVEL)*MarketInfo(OO_symbol,MODE_POINT),Digits);  //minimum stop loss/ take profit level, in points
                                                                                                                    //the module provides safe order opening.
//--- check stop orders for buying
  if(OO_cmd==OP_BUY || OO_cmd==OP_BUYLIMIT || OO_cmd==OP_BUYSTOP)
    {
      double tp = (OO_takeprofit - OO_price)/MarketInfo(OO_symbol, MODE_POINT);
      double sl = (OO_price - OO_stoploss)/MarketInfo(OO_symbol, MODE_POINT);
      if(tp>0 && tp<=stopllvl)
        {
        OO_takeprofit=OO_price+stopllvl+2*MarketInfo(OO_symbol,MODE_POINT);
        }
      if(sl>0 && sl<=stopllvl)
        {
        OO_stoploss=OO_price -(stopllvl+2*MarketInfo(OO_symbol,MODE_POINT));
        }
    }
//--- check stop orders for selling
  if(OO_cmd==OP_SELL || OO_cmd==OP_SELLLIMIT || OO_cmd==OP_SELLSTOP)
    {
      double tp = (OO_price - OO_takeprofit)/MarketInfo(OO_symbol, MODE_POINT);
      double sl = (OO_stoploss - OO_price)/MarketInfo(OO_symbol, MODE_POINT);
      if(tp>0 && tp<=stopllvl)
        {
        OO_takeprofit=OO_price -(stopllvl+2*MarketInfo(OO_symbol,MODE_POINT));
        }
      if(sl>0 && sl<=stopllvl)
        {
        OO_stoploss=OO_price+stopllvl+2*MarketInfo(OO_symbol,MODE_POINT);
        }
    }
//--- while loop
  while(!exit_loop)
    {
      result=OrderSend(OO_symbol,OO_cmd,OO_volume,OO_price,OO_slippage,OO_stoploss,OO_takeprofit,OO_comment,OO_magic,OO_expiration,OO_arrow_color); //attempt to open an order using the specified parameters
      //--- if there is an error when opening an order
      if(result<0)
        {
        Error = GetLastError();                                    //assign a code to an error
        switch(Error)                                              //error enumeration
          {                                                        //order closing error enumeration and an attempt to fix them
            case  2:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(3000);                                      //3 seconds of delay
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt=0;                                        //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case  3:
              RefreshRates();
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case  4:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(3000);                                      //3 seconds of delay
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case  5:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case  6:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(5000);                                      //3 seconds of delay
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case  8:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(7000);                                      //3 seconds of delay
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 64:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case 65:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case 128:
              Sleep(3000);
              RefreshRates();
              continue;                                            //exit switch
            case 129:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  Sleep(3000);                                      //3 seconds of delay
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 130:
              exit_loop=true;                                      //exit while
              break;
            case 131:
              exit_loop = true;                                    //exit while
              break;                                                //exit switch
            case 132:
              Sleep(10000);                                        //sleep for 10 seconds
              RefreshRates();                                      //update data
              //exit_loop = true;                                  //exit while
              break;                                                //exit switch
            case 133:
              exit_loop=true;                                      //exit while
              break;                                                //exit switch
            case 134:
              exit_loop=true;                                      //exit while
              break;                                                //exit switch
            case 135:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 136:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;                                //define one more attempt
                  RefreshRates();
                  break;                                            //exit switch
                }
              if(attempt==attemptMax)
                {
                  attempt = 0;                                      //reset the amount of attempts to zero
                  exit_loop = true;                                  //exit while
                  break;                                            //exit switch
                }
            case 137:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  Sleep(2000);
                  RefreshRates();
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 138:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  Sleep(1000);
                  RefreshRates();
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 139:
              exit_loop=true;
              break;
            case 141:
              Sleep(5000);
              exit_loop=true;
              break;
            case 145:
              exit_loop=true;
              break;
            case 146:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  Sleep(2000);
                  RefreshRates();
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 147:
              if(attempt<attemptMax)
                {
                  attempt=attempt+1;
                  OO_expiration=0;
                  break;
                }
              if(attempt==attemptMax)
                {
                  attempt=0;
                  exit_loop=true;
                  break;
                }
            case 148:
              exit_loop=true;
              break;
            default:
              Print("Error: ",Error);
              exit_loop=true; //exit while
              break;          //other options
          }
        }
      //--- if no errors detected
      else
        {
        if(lang == "Indonesian") {Print("Order berhasil dilakukan. ", result);}
        if(lang == "English") {Print("The order is successfully opened.", result);}
        Error = 0;                                //reset the error code to zero
        break;                                    //exit while
        //errorCount =0;                          //reset the amount of attempts to zero
        }
    }
  return(result);

Mau masukin semua EA disini ternyata g cukup. Untuk selengkapnya silakan di download EAnya dan di BT sepuasnya, masih bisa dikoreksi ataupun ditambahkan strategi lain.
inikan contoh EA yg di MQL5 wkwkwkwk,
 
salam...
ini saya COPAS dari sebuah artikel teman trader kita pada blognya..
jujur saja ni ya, sudah berapa kali saya membaca artikel ini tapi belum juga bisa menciptakan sebuah EA, pasti ada saja ERRORnya..
saya buat Thread ini berharap ada para masta masti share script2 jitu nya di sini, hehehe..
salam trader..
:horree::horree::horree:
sedoooot duluu aaaghh!
 
Back
Top