- Dapatkan gratis robot forex TraderSharing Di sini
Sebelumnya buka meta editor,klik membuat EA baru.
Seperti biasa,dalam membuat EA kita perlu memberi nama EA,koment,perintah order dan magic numbur,lihat script nya di bawah.
/+------------------------------------------------------------------+
//| hometrader.mq4 |
//| Copyright 2018, hometrader Corp |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, TraderSharing Corp"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
input string Nama_EA = "hometrader";
input bool Trade_buy = True;
input bool Trade_sell = True;
input int TP = 100;
input int SL = 3;
input int Slippage = 10;
input int Magic = 777;
input int TrailingStop = 5;
input bool Trailling = True;
input int Max_order = 10;
input double Lots = 0.02;
input int SMA1Periode = 2;
input int SMA2Periode = 14;
input int SMA3Periode = 50;
input int SMA4Periode = 100;
input int SMA5Periode = 200;
double pt=0;
int res;
int wt,tiket;
bool New_Bar;
//| hometrader.mq4 |
//| Copyright 2018, hometrader Corp |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, TraderSharing Corp"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
input string Nama_EA = "hometrader";
input bool Trade_buy = True;
input bool Trade_sell = True;
input int TP = 100;
input int SL = 3;
input int Slippage = 10;
input int Magic = 777;
input int TrailingStop = 5;
input bool Trailling = True;
input int Max_order = 10;
input double Lots = 0.02;
input int SMA1Periode = 2;
input int SMA2Periode = 14;
input int SMA3Periode = 50;
input int SMA4Periode = 100;
input int SMA5Periode = 200;
double pt=0;
int res;
int wt,tiket;
bool New_Bar;
Setelah membuat nama EA dan perintah order,selanjutnya buat parameter logikanya.
Di sini kita akan mencoba menggunakan parameter MA silang.
Di atas sudah kita persiapkan 5 MA .
Kemudian kita buat perintah ordernya seperti di bawah
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
dtrailing();
//---
double dSMA1, dSMA2, dSMA3, dSMA4, dSMA5, dSMA1before, dSMA2before, dSMA3before, dSMA4before, dSMA5before;
dSMA1=iMA(NULL,0,SMA1Periode,0,MODE_SMA,PRICE_CLOSE,0);
dSMA2=iMA(NULL,0,SMA2Periode,0,MODE_SMA,PRICE_CLOSE,0);
dSMA3=iMA(NULL,0,SMA3Periode,0,MODE_SMA,PRICE_CLOSE,0);
dSMA4=iMA(NULL,0,SMA4Periode,0,MODE_SMA,PRICE_CLOSE,0);
dSMA5=iMA(NULL,0,SMA5Periode,0,MODE_SMA,PRICE_CLOSE,0);
dSMA1before=iMA(NULL,0,SMA1Periode,0,MODE_SMA,PRICE_CLOSE,1);
dSMA2before=iMA(NULL,0,SMA2Periode,0,MODE_SMA,PRICE_CLOSE,1);
dSMA3before=iMA(NULL,0,SMA3Periode,0,MODE_SMA,PRICE_CLOSE,1);
dSMA4before=iMA(NULL,0,SMA4Periode,0,MODE_SMA,PRICE_CLOSE,1);
dSMA5before=iMA(NULL,0,SMA5Periode,0,MODE_SMA,PRICE_CLOSE,1);
if(wt!=Time[0]){
if(jumlahorder(0)<Max_order && (dSMA1>dSMA2 && dSMA1before<dSMA2before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA1>dSMA3 && dSMA1before<dSMA3before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_2,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA1>dSMA4 && dSMA1before<dSMA4before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_3,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA1>dSMA5 && dSMA1before<dSMA5before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_4,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA2>dSMA3 && dSMA2before<dSMA3before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_5,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA2>dSMA4 && dSMA2before<dSMA4before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_5,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA2>dSMA5 && dSMA2before<dSMA5before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_5,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA3>dSMA4 && dSMA3before<dSMA4before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_6,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA3>dSMA5 && dSMA3before<dSMA5before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_6,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA4>dSMA5 && dSMA4before<dSMA5before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_7,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(1)<Max_order && (dSMA1<dSMA2) && (dSMA1before>dSMA2before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA1<dSMA3) && (dSMA1before>dSMA3before && Trade_sell))
{tiket=OrderSend(Symbol(),OP_SELL,Lots_2,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA1<dSMA4) && (dSMA1before>dSMA4before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_3,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA1<dSMA5) && (dSMA1before>dSMA5before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_4,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA2<dSMA3) && (dSMA2before>dSMA3before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_5,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA2<dSMA4) && (dSMA2before>dSMA4before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_5,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA2<dSMA5) && (dSMA2before>dSMA5before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_5,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA3<dSMA4) && (dSMA3before>dSMA4before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_6,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA3<dSMA5) && (dSMA3before>dSMA5before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_6,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA4<dSMA5) && (dSMA4before>dSMA5before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_7,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(tiket>0) wt=(int)Time[0];
}
}
//+------------------------------------------------------------------+
if(OrderType()==OP_SELL) {
if((OrderOpenPrice()-Ask)>(pt*TrailingStop)){
if(OrderStopLoss()>(Ask+pt*TrailingStop) || (OrderStopLoss()==0)){
mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+pt*TrailingStop,OrderTakeProfit(),0,Red);
}
}
}
}}
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
dtrailing();
//---
double dSMA1, dSMA2, dSMA3, dSMA4, dSMA5, dSMA1before, dSMA2before, dSMA3before, dSMA4before, dSMA5before;
dSMA1=iMA(NULL,0,SMA1Periode,0,MODE_SMA,PRICE_CLOSE,0);
dSMA2=iMA(NULL,0,SMA2Periode,0,MODE_SMA,PRICE_CLOSE,0);
dSMA3=iMA(NULL,0,SMA3Periode,0,MODE_SMA,PRICE_CLOSE,0);
dSMA4=iMA(NULL,0,SMA4Periode,0,MODE_SMA,PRICE_CLOSE,0);
dSMA5=iMA(NULL,0,SMA5Periode,0,MODE_SMA,PRICE_CLOSE,0);
dSMA1before=iMA(NULL,0,SMA1Periode,0,MODE_SMA,PRICE_CLOSE,1);
dSMA2before=iMA(NULL,0,SMA2Periode,0,MODE_SMA,PRICE_CLOSE,1);
dSMA3before=iMA(NULL,0,SMA3Periode,0,MODE_SMA,PRICE_CLOSE,1);
dSMA4before=iMA(NULL,0,SMA4Periode,0,MODE_SMA,PRICE_CLOSE,1);
dSMA5before=iMA(NULL,0,SMA5Periode,0,MODE_SMA,PRICE_CLOSE,1);
if(wt!=Time[0]){
if(jumlahorder(0)<Max_order && (dSMA1>dSMA2 && dSMA1before<dSMA2before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA1>dSMA3 && dSMA1before<dSMA3before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_2,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA1>dSMA4 && dSMA1before<dSMA4before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_3,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA1>dSMA5 && dSMA1before<dSMA5before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_4,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA2>dSMA3 && dSMA2before<dSMA3before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_5,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA2>dSMA4 && dSMA2before<dSMA4before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_5,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA2>dSMA5 && dSMA2before<dSMA5before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_5,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA3>dSMA4 && dSMA3before<dSMA4before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_6,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA3>dSMA5 && dSMA3before<dSMA5before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_6,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(0)<Max_order && (dSMA4>dSMA5 && dSMA4before<dSMA5before) && Trade_buy)
{tiket=OrderSend(Symbol(),OP_BUY,Lots_7,Ask,1,Ask-SL*pt,Ask+TP*pt,Nama_EA,Magic,0,Green);}
if(jumlahorder(1)<Max_order && (dSMA1<dSMA2) && (dSMA1before>dSMA2before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA1<dSMA3) && (dSMA1before>dSMA3before && Trade_sell))
{tiket=OrderSend(Symbol(),OP_SELL,Lots_2,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA1<dSMA4) && (dSMA1before>dSMA4before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_3,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA1<dSMA5) && (dSMA1before>dSMA5before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_4,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA2<dSMA3) && (dSMA2before>dSMA3before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_5,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA2<dSMA4) && (dSMA2before>dSMA4before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_5,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA2<dSMA5) && (dSMA2before>dSMA5before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_5,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA3<dSMA4) && (dSMA3before>dSMA4before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_6,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA3<dSMA5) && (dSMA3before>dSMA5before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_6,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(jumlahorder(1)<Max_order && (dSMA4<dSMA5) && (dSMA4before>dSMA5before) && Trade_sell)
{tiket=OrderSend(Symbol(),OP_SELL,Lots_7,Bid,1,Bid+SL*pt,Bid-TP*pt,Nama_EA,Magic,0,Red);}
if(tiket>0) wt=(int)Time[0];
}
}
//+------------------------------------------------------------------+
if(OrderType()==OP_SELL) {
if((OrderOpenPrice()-Ask)>(pt*TrailingStop)){
if(OrderStopLoss()>(Ask+pt*TrailingStop) || (OrderStopLoss()==0)){
mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+pt*TrailingStop,OrderTakeProfit(),0,Red);
}
}
}
}}
Kemudian compile,dan EA siap di gunakan.
NB.
Dalam pembuatan EA memang bisa di katakan mudah,namun tingkat kesulitan nya adalah bagaimana EA dapat profitabel dan bisa di biarkan run tanpa perlu di pantau.
jadi selain script EA,yang terpenting dalam pembuatan robot forex adalah tekhnik yang di tanam kedalam EA.
Karena jika sampai salah menanamkan tekhnik,justru EA akan menghabiskan modal yang anda miliki.
Jika anda ingin menggunakan EA untuk real account, lebih baik menggunakan EA yang sudah terbukti profitabel.
Seperti halnya EA yang kami refiew di post sebelumnya.
EA yang di buat oleh ahli script dan ahli tekhnik trading dapat bertahan di semua kondisi harga.
Baca juga:
& Home Trader