Kursus Forex Solo Tempat Belajar Trading Forex Solo Pelatihan Forex Solo Edukasi Forex Solo Training Forex Solo Privat Membuat EA Robot Forex

BACA TUTORIAL: CARA DAFTAR MT4 FOREX!

Cara Membuat EA Robot Forex Jebakan

Cara Membuat EA Robot Forex Jebakan, Belajar Menulis Coding MQl4 Untuk Membuat EA Jebakan. Tujuannya Create Robot Forex Jebakan Ini Adalah Akan diGunakan Untuk Trading Waktu Ada News Berita NFP (Non Farm Payroll) Yang diRilis atau diUmumkan Setiap Hari Jumat Pertama Tiap Bulan.

Coding MQL4 Fungsi Delete Pending Order Buy Stop:

Coding MQL4 Fungsi Cek OP Sell Aktif:

Coding MQL4 Fungsi Op Sell Stop:

Coding MQL4 Fungsi Delete Pending Order Sell Stop:

Coding MQL4 Fungsi Cek OP Buy Aktif

Coding MQL4 Fungsi Pending Order Buy Stop Aktif

Coding MQL4 Fungsi Cek Ada Tidak Order Yang Aktif

Coding MQL4 Fungsi OnTick

Coding MQL4 Fungsi Init dan Deinit

Coding MQL4 Variable EA Jebakan

Script EA Jebakan Trading Berita NFP (NonFarm Payroll / Non-Farm Employment Change)

////+------------------------------------------------------------------+
//|                                                  EA JEBAKAN .mq4 |
//|                                                            Admin |
//|                                           http://daftarmt4.my.id |
//+------------------------------------------------------------------+
#property copyright "Copyright © Admin"
#property link      "http://daftarmt4.my.id"

#include <stdlib.mqh>
#include <WinUser32.mqh>

extern string NamaEA       = "EA ROBOT FOREX JEBAKAN";
extern double SellLots4    = 0.1;
extern int SellStoploss4   = 20;
extern int SellTakeprofit4 = 20;
extern int PriceOffset4    = 30; //jarak sell stop dibawah harga running
extern double BuyLots3     = 0.1;
extern int BuyStoploss3    = 20;
extern int BuyTakeprofit3  = 20;
extern int PriceOffset3    = 30; //jarak buy stop di atas harga running

double PipValue=1;    
bool Terminated = false;
string LF = "\n";  
int NDigits = 4;   
int ObjCount = 0;  
int current = 0;   
int varylots[101];

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
{
    NDigits = Digits;    
    if (false) ObjectsDeleteAll();      
    Comment("");    
    return (0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
{
    if (false) ObjectsDeleteAll();    
    return (0);
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
    if (Bars < 10)
    {
        return ;
    }
    if (Terminated == true)
    {
        return ;
    }
    OnEveryTick();
    return ;
}
//+------------------------------------------------------------------+
void OnEveryTick()
{
    PipValue = 1;
    if (NDigits == 3 || NDigits == 5) PipValue = 10;
    CheckNoOrderAktif();
    CheckOrderBuyExists();
    CheckOrderSellExists(); 
}
//+------------------------------------------------------------------+
void CheckNoOrderAktif() //fungsi cek ada tidak order yang aktif
{
    bool exists = false;
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderSymbol() == Symbol())
        {
            exists = true;
        }
    }
    
    if (exists == false)
    {
    
     if(Hour()==15 && Minute()==25) //coding jam 19.25 wib, rilis NFP jam 19.30 wib
       {   
        SellPendingOrder();
        BuyPendingOrder();
        }    
    }    
}
//+------------------------------------------------------------------+
void BuyPendingOrder() //fungsi pending order buy stop
{
    int expire = 0; //TimeCurrent() + 60 * 240;
    double price = NormalizeDouble(Ask, NDigits) + PriceOffset3*PipValue*Point;
    double SL = price - BuyStoploss3*PipValue*Point;
    if (BuyStoploss3 == 0) SL = 0;
    double TP = price + BuyTakeprofit3*PipValue*Point;
    if (BuyTakeprofit3 == 0) TP = 0;
    if (240 == 0) expire = 0;
    int ticket = OrderSend(Symbol(),OP_BUYSTOP,BuyLots3,price,4,SL,TP,"buystop1",1,expire,Blue);
    if (ticket == -1)
    {
        Print("OrderSend() error - ", ErrorDescription(GetLastError()));
    }    
}
//+------------------------------------------------------------------+
void CheckOrderBuyExists() //fungsi cek op buy jika eksis
{
    bool exists = false;
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
        {
            exists = true;
        }
    }
    else
    {
        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
    }
    if (exists)
    {
        DeletePendingOrderSellStop();  
    }
}
//+------------------------------------------------------------------+
void DeletePendingOrderSellStop() //fungsi delete sell stop
{
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_SELLSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == 11)
        {
            bool ret = OrderDelete(OrderTicket(), Red);
            
            if (ret == false)
            {
                Print("OrderDelete() error - ", ErrorDescription(GetLastError()));
            }
        }
    } 
}
//+------------------------------------------------------------------+
void SellPendingOrder() //fungsi op pending order sell stop
{
    int expire = 0; //TimeCurrent() + 60 * 240;
    //int expire = TimeCurrent() + 60 * 240;
    double price = NormalizeDouble(Bid, NDigits) - PriceOffset4*PipValue*Point;
    double SL = price + SellStoploss4*PipValue*Point;
    if (SellStoploss4 == 0) SL = 0;
    double TP = price - SellTakeprofit4*PipValue*Point;
    if (SellTakeprofit4 == 0) TP = 0;
    //if (240 == 0) expire = 0;
    int ticket = OrderSend(Symbol(),OP_SELLSTOP,SellLots4,price,4,SL,TP,"sellstop1",11,expire,Red);
    if (ticket == -1)
    {
        Print("OrderSend() error - ", ErrorDescription(GetLastError()));
    }  
}
//+------------------------------------------------------------------+
void CheckOrderSellExists() //fungsi cek op sell aktif
{
    bool exists = false;
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 11)
        {
            exists = true;
        }
    }
    else
    {
        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
    }
    
    if (exists)
    {
        DeletePendingOrderBuyStop();
        
    }
}
//+------------------------------------------------------------------+
void DeletePendingOrderBuyStop() //fungsi delete pending order buy stop
{
    for (int i=OrdersTotal()-1; i >= 0; i--)
    
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    
    {
        if (OrderType()==OP_BUYSTOP && OrderSymbol()==Symbol() && OrderMagicNumber()==1)
        
        {
            bool ret = OrderDelete(OrderTicket(), Blue);
            
            if (ret == false)
            
            {
                Print("OrderDelete() error - ", ErrorDescription(GetLastError()));
            } 
        }
    } 
}
//+------------------------------------------------------------------+

Demikian Tutorial Cara Membuat EA Robot Forex Jebakan, Belajar Menulis Coding MQl4 Untuk Membuat EA Jebakan Yang Dapat Kami Sampaikan Kepada Anda, Semoga Bermanfaat.

0 comments: