Tempat belajar forex untuk pemula dan advanced, bisa belajar trading forex dengan cara manual ataupun automatic dengan robot forex / EA

Cara Membuat EA Martingale 5 Level

Belajar Membuat EA Cara Membuat EA Martingale 5 Level. Transaksi EAnya Sebanyak 5 Kali. Transaksi Pertama Lotsnya Pakai 0.01, Transaksi kedua Lotsnya Pakai 0.02, Transaksi Ketiga Lotsnya Pakai 0.04, Transaksi keempat Lotsnya Pakai 0.08, Transaksi kelima Lotsnya Pakai 0.16. Jarak Transaksinya Antara Transaksi 1(pertama), ke-2, ke-3, ke-4 & ke-5 Adalah 100 pips. Tidak ada SLnya Sebab EAnya Tidak dipasang StopLoss. TP in Money atau Target TakeProfit EAnya Adalah Lebih Besar atau Sama Dengan  25 Dollars.

SINTAQ / SCRIPT / CODING MQL4 UNTUK MEMBUAT EA MARTINGALE:

//====

//+------------------------------------------------------------------+

//|                                        EA MARTINGALE 5 LEVEL.mq4 |

//|                                                       Forex Solo |

//|                                      http://solo.kursusforex.net |

//+------------------------------------------------------------------+


#property copyright "Copyright © 2021 Forex Solo"

#property link      "http://solo.kursusforex.net"


#include <stdlib.mqh>

#include <WinUser32.mqh>


extern double Lots_Buy1  = 0.01;

extern double Lots_Buy2  = 0.02;

extern double Lots_Buy3  = 0.04;

extern double Lots_Buy4  = 0.08;

extern double Lots_Buy5 = 0.16;

extern double Jarak_OpBuyKe2   = -1;

extern double Jarak_OpBuyKe3   = -2;

extern double Jarak_OpBuyKe4   = -3;

extern double Jarak_OpBuyKe5   = -4;

extern double TP_inMoney = 25;


double PipValue          = 1;    

bool Terminated          = false;

string LF                = "\n"; 

int NDigits              = 4;   

int ObjCount             = 0;  

int current              = 0;   

int varylots[101]; 


int Count104             = 0;


//+------------------------------------------------------------------+

//| 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)

    {

        Comment("Tidak cukup bars");

        return;

    }

    if (Terminated == true)

    {

        Comment("EA dihentikan");

        return;

    }

    

    SetiapHargaBergerak();

    return;

}


void SetiapHargaBergerak()

{

    PipValue = 1;

    if (NDigits == 3 || NDigits == 5) PipValue = 10;

    

    CheckTransaksiTerbuka1();

    CheckTransaksiTerbuka2();

    CheckTransaksiTerbuka3();

    CheckTransaksiTerbuka4();

    InformasiAkunForex();

    JikaTidakAdaTransaksiYangAktif();

    CheckTransaksiSudahLabaAtauMasihRugi();

    

}


void CheckTransaksiTerbuka1()

{

    double profit = 0;

    for (int i=OrdersTotal()-1; i >= 0; i--)

    {

        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

        {

            if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)

            {

                profit += OrderProfit();

            }

        }

        else

        {

            Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

        }

    }

    

    if (profit < Jarak_OpBuyKe2)

    {

        BilaPesananTransaksiTidakAda1();

        

    }

}


void BilaPesananTransaksiTidakAda1()

{

    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() == 2)

        {

            exists = true;

        }

    }

    else

    {

        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

    }

    

    if (exists == false)

    {

        TransaksiBuyId2();

        

    }

}


void TransaksiBuyId2()

{

    double SL = Ask - 0*PipValue*Point;

    if (0 == 0) SL = 0;

    double TP = Ask + 0*PipValue*Point;

    if (0 == 0) TP = 0;

    int ticket = -1;

    if (true)

    ticket = OrderSend(Symbol(), OP_BUY, Lots_Buy2, Ask, 4, 0, 0, "beli 2", 2, 0, Blue);

    else

    ticket = OrderSend(Symbol(), OP_BUY, Lots_Buy2, Ask, 4, SL, TP, "beli 2", 2, 0, Blue);

    if (ticket > -1)

    {

        if (true)

        {

            bool sel = OrderSelect(ticket, SELECT_BY_TICKET);

            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);

            if (ret == false)

            Print("OrderModify() error - ", ErrorDescription(GetLastError()));

        }

            

    }

    else

    {

        Print("OrderSend() error - ", ErrorDescription(GetLastError()));

    }

}


void  CheckTransaksiTerbuka2()

{

    double profit = 0;

    for (int i=OrdersTotal()-1; i >= 0; i--)

    {

        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

        {

            if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)

            {

                profit += OrderProfit();

            }

        }

        else

        {

            Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

        }

    }

    

    if (profit < Jarak_OpBuyKe3)

    {

        BilaPesananTransaksiTidakAda2();

        

    }

}


void BilaPesananTransaksiTidakAda2()

{

    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() == 3)

        {

            exists = true;

        }

    }

    else

    {

        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

    }

    

    if (exists == false)

    {

        TransaksiBuy3();

        

    }

}


void TransaksiBuy3()

{

    double SL = Ask - 0*PipValue*Point;

    if (0 == 0) SL = 0;

    double TP = Ask + 0*PipValue*Point;

    if (0 == 0) TP = 0;

    int ticket = -1;

    if (true)

    ticket = OrderSend(Symbol(), OP_BUY, Lots_Buy3, Ask, 4, 0, 0, "beli 3", 3, 0, Blue);

    else

    ticket = OrderSend(Symbol(), OP_BUY, Lots_Buy3, Ask, 4, SL, TP, "beli 3", 3, 0, Blue);

    if (ticket > -1)

    {

        if (true)

        {

            bool sel = OrderSelect(ticket, SELECT_BY_TICKET);

            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);

            if (ret == false)

            Print("OrderModify() error - ", ErrorDescription(GetLastError()));

        }

            

    }

    else

    {

        Print("OrderSend() error - ", ErrorDescription(GetLastError()));

    }

}


void CheckTransaksiTerbuka3()

{

    double profit = 0;

    for (int i=OrdersTotal()-1; i >= 0; i--)

    {

        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

        {

            if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)

            {

                profit += OrderProfit();

            }

        }

        else

        {

            Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

        }

    }

    

    if (profit < Jarak_OpBuyKe4)

    {

        JikaTidakAdaTransaksiYangAktif2();

        

    }

}


void JikaTidakAdaTransaksiYangAktif2()

{

    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() == 4)

        {

            exists = true;

        }

    }

    else

    {

        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

    }

    

    if (exists == false)

    {

        TransaksiBuy4();

        

    }

}


void TransaksiBuy4()

{

    double SL = Ask - 0*PipValue*Point;

    if (0 == 0) SL = 0;

    double TP = Ask + 0*PipValue*Point;

    if (0 == 0) TP = 0;

    int ticket = -1;

    if (true)

    ticket = OrderSend(Symbol(), OP_BUY, Lots_Buy4, Ask, 4, 0, 0, "beli 4", 4, 0, Blue);

    else

    ticket = OrderSend(Symbol(), OP_BUY, Lots_Buy4, Ask, 4, SL, TP, "beli 4", 4, 0, Blue);

    if (ticket > -1)

    {

        if (true)

        {

            bool sel = OrderSelect(ticket, SELECT_BY_TICKET);

            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);

            if (ret == false)

            Print("OrderModify() error - ", ErrorDescription(GetLastError()));

        }

            

    }

    else

    {

        Print("OrderSend() error - ", ErrorDescription(GetLastError()));

    }

}


void CheckTransaksiTerbuka4()

{

    double profit = 0;

    for (int i=OrdersTotal()-1; i >= 0; i--)

    {

        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

        {

            if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)

            {

                profit += OrderProfit();

            }

        }

        else

        {

            Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

        }

    }

    

    if (profit < Jarak_OpBuyKe5)

    {

        JikaTidakAdaTransaksiYangAktif3();

        

    }

}


void JikaTidakAdaTransaksiYangAktif3()

{

    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() == 5)

        {

            exists = true;

        }

    }

    else

    {

        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

    }

    

    if (exists == false)

    {

        TransaksiBuy5();

        

    }

}


void TransaksiBuy5()

{

    double SL = Ask - 0*PipValue*Point;

    if (0 == 0) SL = 0;

    double TP = Ask + 0*PipValue*Point;

    if (0 == 0) TP = 0;

    int ticket = -1;

    if (true)

    ticket = OrderSend(Symbol(), OP_BUY, Lots_Buy5, Ask, 4, 0, 0, "beli 5", 5, 0, Blue);

    else

    ticket = OrderSend(Symbol(), OP_BUY, Lots_Buy5, Ask, 4, SL, TP, "beli 5", 5, 0, Blue);

    if (ticket > -1)

    {

        if (true)

        {

            bool sel = OrderSelect(ticket, SELECT_BY_TICKET);

            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);

            if (ret == false)

            Print("OrderModify() error - ", ErrorDescription(GetLastError()));

        }

            

    }

    else

    {

        Print("OrderSend() error - ", ErrorDescription(GetLastError()));

    }

}


void InformasiAkunForex()

{

    string temp = "EA MARTINGALE 5 LEVEL\nExecuted : " + Count104 + "\n"

    + "Spread: " + DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD)/PipValue, 2)+ "\n"

    + "------------------------------------------------\n"

    + "ACCOUNT INFORMATION:\n"

    + "\n"

    + "Account Name:     " + AccountName()+ "\n"

    + "Account Leverage:     " + DoubleToStr(AccountLeverage(), 0)+ "\n"

    + "Account Balance:     " + DoubleToStr(AccountBalance(), 2)+ "\n"

    + "Account Equity:     " + DoubleToStr(AccountEquity(), 2)+ "\n"

    + "Free Margin:     " + DoubleToStr(AccountFreeMargin(), 2)+ "\n"

    + "Used Margin:     " + DoubleToStr(AccountMargin(), 2)+ "\n"

    + "------------------------------------------------\n";

    Comment(temp);

    Count104++;

    

}


void JikaTidakAdaTransaksiYangAktif()

{

    bool exists = false;

    for (int i=OrdersTotal()-1; i >= 0; i--)

    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

    {

        if (OrderSymbol() == Symbol())

        {

            exists = true;

        }

    }

    else

    {

        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

    }

    

    if (exists == false)

    {

        BuyOrder119();

        

    }

}


void BuyOrder119()

{

    double SL = Ask - 0*PipValue*Point;

    if (0 == 0) SL = 0;

    double TP = Ask + 0*PipValue*Point;

    if (0 == 0) TP = 0;

    int ticket = -1;

    if (true)

    ticket = OrderSend(Symbol(), OP_BUY, Lots_Buy1, Ask, 4, 0, 0, "beli 1", 1, 0, Blue);

    else

    ticket = OrderSend(Symbol(), OP_BUY, Lots_Buy1, Ask, 4, SL, TP, "beli 1", 1, 0, Blue);

    if (ticket > -1)

    {

        if (true)

        {

            bool sel = OrderSelect(ticket, SELECT_BY_TICKET);

            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);

            if (ret == false)

            Print("OrderModify() error - ", ErrorDescription(GetLastError()));

        }

            

    }

    else

    {

        Print("OrderSend() error - ", ErrorDescription(GetLastError()));

    }

}


void CheckTransaksiSudahLabaAtauMasihRugi()

{

    double profit = 0;

    for (int i=OrdersTotal()-1; i >= 0; i--)

    {

        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

        {

            if (OrderSymbol() == Symbol())

            {

                profit += OrderProfit();

            }

        }

        else

        {

            Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

        }

    }

    

    if (profit >= TP_inMoney)

    {

        CloseSemuaTransaksi();

        

    }

}


void CloseSemuaTransaksi()

{

    int orderstotal = OrdersTotal();

    int orders = 0;

    int ordticket[90][2];

    for (int i = 0; i < orderstotal; i++)

    {

        bool sel = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

        if (OrderType() != OP_BUY || OrderSymbol() != Symbol())

        {

            continue;

        }

        ordticket[orders][0] = OrderOpenTime();

        ordticket[orders][1] = OrderTicket();

        orders++;

    }

    if (orders > 1)

    {

        ArrayResize(ordticket,orders);

        ArraySort(ordticket);

    }

    for (i = 0; i < orders; i++)

    {

        if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)

        {

            bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Blue);

            if (ret == false)

            Print("OrderClose() error - ", ErrorDescription(GetLastError()));

        }

    }

    

}


//+------------------------------------------------------------------+


//====

EA Martingale Ini Kalau diJalankan Maka EA akan Melakukan Transaksi Buy Sebanyak 5 Kali dan Kalau Transaksinya Sudah Laba 25 Dollars, Maka Semua Transaksi Buynya Akan diClose Oleh EA.

EA Ini Juga Dapat diUbah Menjadi EA Averaging, Yang diUbah Adalah Lots_Buy2 s.d Lots_Buy5. EA Martingale Ini Supaya Bisa Menjadi EA Averaging Ganti Settingan Lotsnya Tersebut Semua Menjadi 0.01. Contohnya Lots_Buy2 0.01; Lots_Buy3 0.01; Lots_Buy4 0.01; Lots_Buy5 0.01; Mudahkan Cara Menggantinya?

Demikian Panduan Cara Membuat EA Martingale 5 Level Yang Dapat Kami Bagikan kepada Anda, Semoga Bermanfaat. Kalau ada pertanyaan atau Anda butuh bimbingan pelatihan membuat EA robot forex, silahkan Anda Hub 087835278694.

0 komentar:



Tutorialnya, klik disini!

HP Android Untuk Trading

Spesifikasi HP Android Yang Baik
Untuk Trading Forex :


  • RAM minimal 2 GB
  • Display LCDnya minimal 5 inc
  • Sudah Support jaringan 4G

CARA DAFTAR INSTAFOREX