Pada goresan pena ini aku akan membuatkan tutorial ialah bagaimana cara menciptakan robot forex untuk pemula pada khususnya.
Seperti kita ketahui, berbagai EA yang beredar diluar sana, ada yang gratis, ada pula yang berbayar. Mungkin Sobat pernah mencobanya satu-persatu, mencari yang andal dari yang terhebat, kasarannya itu mencari yang tepat atau holy grail .
Baiklah eksklusif saja kita mulai menciptakan robot forex, sebisanya, yang penting jadi dulu lah.
Pertama, buka Meta Editor, File - New , kemudian muncul gambar berikut ini:
Klik Next terus, ikuti saja apa maunya, hingga muncul code begini:
//+------------------------------------------------------------------+
//| NubiCoder.mq4 |
//| Copyright 2016 @ nubicoder.blogspot.com |
//| https://nubicoder.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016 @ nubicoder.blogspot.com"
#property link "https://nubicoder.blogspot.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()
{
//---
}
//+------------------------------------------------------------------+
//| NubiCoder.mq4 |
//| Copyright 2016 @ nubicoder.blogspot.com |
//| https://nubicoder.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016 @ nubicoder.blogspot.com"
#property link "https://nubicoder.blogspot.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()
{
//---
}
//+------------------------------------------------------------------+
Dari sini kita telah final menciptakan template awal, atau kerangka dasar, atau apalah istilahnya itu. Sekarang tinggal memasukkan perintah-perintah agar robotnya dapat berjalan.
Kita gunakan indikator MA saja ya, untuk percobaan, sebab gampang. Rumusnya logikanya begini:
- Jika Ask price diatas MA periode 14, maka Buy.
- Jika Bid price dibawah MA periode 14, maka Sell.
- Input Lot = 0.1 , SL 20 pip dan TP 20 pip.
Pertama kita tuliskan dulu arahan inputnya, kodenya begini:
input double Lot = 0.1;
input int TP = 200;
input int SL = 200;
input int TP = 200;
input int SL = 200;
arahan diatas kita tempatkan tepat dibawah #property sebelum int OnInit()
Secara default nilai 20 pip itu ditulis 200, dan ini belum dapat membedakan antara 4 dan 5 digit. Nanti saja kita beri kodenya.
Sekarang kita masukkan perintah logika kita diatas, kodenya begini:
Rumus MA
double MA = iMA(NULL,NULL,14,0,0,0,1);
Logika OP nya
if (Ask>MA){
int ticket = OrderSend(NULL,OP_BUY,Lot,Ask,3,Ask-SL*Point,Ask+TP*Point);
}
if (Bid<MA) {
int ticket = OrderSend(NULL,OP_SELL,Lot,Bid,3,Bid+SL*Point,Bid-TP*Point);
}
int ticket = OrderSend(NULL,OP_BUY,Lot,Ask,3,Ask-SL*Point,Ask+TP*Point);
}
if (Bid<MA) {
int ticket = OrderSend(NULL,OP_SELL,Lot,Bid,3,Bid+SL*Point,Bid-TP*Point);
}
Tempatkan arahan Rumus dan Logika itu di bawah void OnTick() sehabis kurung kurawal {
akhirnya begini:
//+------------------------------------------------------------------+
//| NubiCoder.mq4 |
//| Copyright 2016 @ nubicoder.blogspot.com |
//| https://nubicoder.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016 @ nubicoder.blogspot.com"
#property link "https://nubicoder.blogspot.com"
#property version "1.00"
#property strict
input double Lot = 0.1;
input int TP = 200;
input int SL = 200;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
double MA = iMA(NULL,NULL,14,0,0,0,1);
if (OrdersTotal()==0) {
if (Ask>MA){
int ticket = OrderSend(NULL,OP_BUY,Lot,Ask,3,Ask-SL*Point,Ask+TP*Point);
}
if (Bid<MA) {
int ticket = OrderSend(NULL,OP_SELL,Lot,Bid,3,Bid+SL*Point,Bid-TP*Point);
}
}
}
//+------------------------------------------------------------------+
//| NubiCoder.mq4 |
//| Copyright 2016 @ nubicoder.blogspot.com |
//| https://nubicoder.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016 @ nubicoder.blogspot.com"
#property link "https://nubicoder.blogspot.com"
#property version "1.00"
#property strict
input double Lot = 0.1;
input int TP = 200;
input int SL = 200;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
double MA = iMA(NULL,NULL,14,0,0,0,1);
if (OrdersTotal()==0) {
if (Ask>MA){
int ticket = OrderSend(NULL,OP_BUY,Lot,Ask,3,Ask-SL*Point,Ask+TP*Point);
}
if (Bid<MA) {
int ticket = OrderSend(NULL,OP_SELL,Lot,Bid,3,Bid+SL*Point,Bid-TP*Point);
}
}
}
//+------------------------------------------------------------------+
Setelah itu, Compile, dan selesailah EA pertama kita. Coba jalankan di strategy tester, jikalau dapat jalan, berarti berhasil.
Demikian secara singkat cara menciptakan Robot Forex untuk pemula. Semoga bermanfaat.
0 Response to "Cara Menciptakan Robot Forex (Ea) Untuk Pemula"
Post a Comment