1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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 :)
    Dismiss Notice

Tutorial Buat EA Mudah Rame-rame seru (by WAME)

Discussion in 'Belajar MQL dari Nol' started by Yasir Arafat, 02 Jun 2016.

  1. Andri_Susilo

    Andri_Susilo Member Credit Hunter

    Equity
    Credit
    Ref Point
    lanjuuuuuuuuuutttttttttttt master
     
  2. Murayrich

    Murayrich Member Credit Hunter

    Equity
    Credit
    Ref Point
    klo mau bikin ea yg open order berdasarkan previous candle, dan exit berdasarkan close candle saat ini.
    klo previous canlde close hige maka open buy.
    klo previous candle close down maka open sell.
    simple tp profitable klo di tf dayli.
    sourchcode nya apa aja ya master?
     
  3. SANLANA

    SANLANA Active Member Credit Hunter

    Equity
    Credit
    Ref Point
    kan tinggal kopas aja gan..g perlu di ketik dari nol....
     
  4. Artomoro Trader

    Artomoro Trader Member Credit Hunter

    Equity
    Credit
    Ref Point
    Help gan, kalau EA keterangannya kayak ginie kenapa ya??? dia order ngasih modified TP tapi ada seperti itu malah TP nggak ke set... Bagaimana biar TP tetep berusaha di set EA ya?
     

    Attached Files:

    • 2.png
      2.png
      File size:
      4.9 KB
      Views:
      21
  5. cybersukabumi

    cybersukabumi Member Credit Hunter

    Equity
    Credit
    Ref Point
    Murayrich mungkin ini bisa dicoba...

    void OnTick(){
    int JumlahOrder = OrdersTotal(); // untuk mengetahui jumlah order
    double OpenCandel = Open[1]; //melihat nilai open candle sift 1
    double CloseCandel= Close[1]; //melihat nilai close candle sift 1
    double lot = 0.1;
    bool SinyalBuy = false; // sebelum kita melihat kondisi candle sinyal harus false dulu
    bool SinyalSell= false; // sebelum kita melihat kondisi candle sinyal harus false dulu

    if(OpenCandel<CloseCandel)SinyalBuy =1; // menentukan sinyal buy jika candle naik
    if(OpenCandel>CloseCandel)SinyalSell =1;

    if(SinyalBuy) close(1); // close sell saat sinyal buy ( candle up)
    if(SinyalSell)close(0); // close buy saat sinyal sell( candle down)

    //OrderSend(symb,cmd,lot,price . . . .
    if(JumlahOrder<1&&SinyalBuy==true ) { OrderSend( Symbol(), 0, lot, Ask, 3, 0, 0, "", 0, 0,clrNONE );}// send buy
    if(JumlahOrder<1&&SinyalSell==true ) { OrderSend( Symbol(), 1, lot, Bid, 3, 0, 0, "", 0, 0,clrNONE );}// send sell
    // perbedaan order send buy dan sell ada pada cmd dan price
    }

    void close( int x ) // x adalah tipe OP yang akan di close 0=buy 1=sell
    { // ini mulai start fungsi
    for (int i= OrdersTotal()-1 ; i >= 0; i--)
    {
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
    if (OrderSymbol() == Symbol()&&OrderType()==x )
    { if(OrderType()==0 ) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue); }
    if(OrderType()==1 ) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Red); }
    }
    }
    }
     
  6. omnyadafa

    omnyadafa New Member

    Equity
    Credit
    Ref Point
    nyimak om :think:
     
  7. Henipml

    Henipml New Member

    Equity
    Credit
    Ref Point
    Yasir Arafat : Mantab Codingnya .. Ok banget masukannya, sangat membantu..
     
  8. gilang0606

    gilang0606 New Member

    Equity
    Credit
    Ref Point
    gan bantuin dong ini saya ada script ea mau nambahin marti nya eror trus,ini pengennya kalau sudah kena sl lgsg OP lagi di titik sl trsebut dengn double lot


    //+------------------------------------------------------------------+
    //|
    //|
    //|
    //+------------------------------------------------------------------+
    #property copyright "KUSUS UNTUK SODAKOH "
    #property link "rejeki.com"
    #property version "1.00"
    #property strict
    #define __STRATEGY_MAGIC 557835
    #define __SLEEP_AFTER_EXECUTION_FAIL 400
    //Input Variable
    input double _Take_Profit = 500; //Bismillah
    input double _Stop_Loss = 1000; //belum rejeki
    input int _EMA_60 = 60; // goib 1
    input int _SMA_90 = 90; // goib 2
    //input int _EMA_70 = 70; // EMA 3
    input double _Lot = 0.01; //Lot
    //GLOBAL DECLARATION
    double _iEMA_60;
    double _iSMA_90;
    int init() {
    return(0);
    }

    //Local Declaration
    bool _Buy = false;
    bool _Sell = false;

    _iEMA_60 = iMA ("",0,_EMA_60,0,MODE_EMA,0,0);
    _iSMA_90 = iMA ("",0,_SMA_90,0,MODE_EMA,0,0);

    //--------------------- ARGUMEN EA ------------------
    // ARGUMEN BUY
    if(_iEMA_60 > _iSMA_90 &&
    iClose ("",0,1) > _iEMA_60 &&
    _iEMA_60 > iOpen("",0,1)) _Buy = Buy (1,_Lot,0,_Stop_Loss,0,_Take_Profit,10,1,0,"");

    //ARGUMEN SELL
    if(_iEMA_60 < _iSMA_90 &&
    iClose ("",0,1) < _iEMA_60 &&
    _iEMA_60 < iOpen("",0,1)) _Sell = Sell (1,_Lot,0,_Stop_Loss,0,_Take_Profit,10,1,0,"");
    return(0);
    }
    bool __selectOrderByMagic(int magic, string symbol)
    {
    for(int i = 0; i < OrdersTotal(); i++)
    {
    if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == __STRATEGY_MAGIC + magic && OrderSymbol() == symbol)
    return(true);
    }
    return(false);
    }
    bool Close_All_Trades(int MagicIndex)
    {
    int total = OrdersTotal();
    int type;
    bool result = true;
    for(int i=total-1;i>=0;i--)
    {
    if(!OrderSelect(i, SELECT_BY_POS)) continue;
    if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != Symbol()) continue;
    type = OrderType();
    if(type == OP_BUY)
    {
    if(!OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ))
    {
    result = false;
    Sleep(__SLEEP_AFTER_EXECUTION_FAIL);
    }
    }else if(type == OP_SELL)
    {
    if(!OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ))
    {
    result = false;
    Sleep(__SLEEP_AFTER_EXECUTION_FAIL);
    }
    }
    }
    return(result);
    }
    bool Buy(int MagicIndex, double Lots, int StopLossMethod, double StopLossPoints, int TakeProfitMethod, double TakeProfitPoints, int Slippage, int MaxOpenTrades,
    int MaxFrequencyMins, string TradeComment)
    {
    static double pipSize = 0;
    if(pipSize == 0) pipSize = Point * (1 + 9 * (Digits == 3 || Digits == 5));
    double sl = 0, tp = 0;
    double stopLossPoints = 0, takeProfitPoints = 0;

    int numberOfOpenTrades = 0;

    for(int i=OrdersTotal()-1;i>=0;i--){
    if(!OrderSelect(i, SELECT_BY_POS)) continue;
    if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != Symbol()) continue;
    numberOfOpenTrades ++;
    }
    if(MaxOpenTrades > 0 && numberOfOpenTrades >= MaxOpenTrades) return(false);
    if(MaxFrequencyMins > 0)
    {
    int recentSeconds = MaxFrequencyMins * 60;
    for(int i=OrdersTotal()-1;i>=0;i--){
    if(!OrderSelect(i, SELECT_BY_POS)) continue;
    if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != Symbol()) continue;
    if(TimeCurrent() - OrderOpenTime() < recentSeconds) return(false);
    }
    int hstTotal=OrdersHistoryTotal();

    for(int i=hstTotal-1;i>=0;i--)
    {
    if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) continue;
    if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != Symbol()) continue;
    if(TimeCurrent() - OrderOpenTime() < recentSeconds) return(false);
    break;
    }
    }

    if(Lots < MarketInfo(Symbol(),MODE_MINLOT)) return(false);

    if(AccountFreeMarginCheck(Symbol(), OP_SELL,Lots) <= 0) {
    Print("Buy error: insufficient capital");
    return(false);
    }
    if (StopLossPoints > 0)
    {
    if(StopLossMethod == 0)
    {
    sl = NormalizeDouble(Ask - StopLossPoints * Point, Digits);
    stopLossPoints = StopLossPoints;
    }
    else if (StopLossMethod == 1)
    {
    sl = NormalizeDouble(Ask - StopLossPoints * pipSize, Digits);
    stopLossPoints = StopLossPoints * (1 + 9 * (Digits == 3 || Digits == 5));
    }
    else
    {
    sl = StopLossPoints;
    stopLossPoints = (Ask - sl)/Point;
    }
    }

    if (TakeProfitPoints > 0)
    {
    if(TakeProfitMethod == 0)
    {
    tp = NormalizeDouble(Ask + TakeProfitPoints * Point, Digits);
    takeProfitPoints = TakeProfitPoints;
    }
    else if (TakeProfitMethod == 1)
    {
    tp = NormalizeDouble(Ask + TakeProfitPoints * pipSize, Digits);
    takeProfitPoints = TakeProfitPoints * (1 + 9 * (Digits == 3 || Digits == 5));
    }
    else
    {
    tp = TakeProfitPoints;
    takeProfitPoints = (tp - Ask)/Point;
    }
    }

    double stopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL) + MarketInfo(Symbol(),MODE_SPREAD);

    if( (sl > 0 && stopLossPoints <= stopLevel) || (tp > 0 && takeProfitPoints <= stopLevel) )
    {
    Print("Cannot Buy: Stop loss and take profit must be at least "
    + DoubleToStr(MarketInfo(Symbol(),MODE_STOPLEVEL) + MarketInfo(Symbol(),MODE_SPREAD),0)
    + " points away from the current price");
    return (false);
    }

    RefreshRates();
    int result = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, sl, tp, "EA BUY " + "(" + WindowExpertName() + ") " + TradeComment, __STRATEGY_MAGIC + MagicIndex);

    if (result == -1){
    Print("Failed to Buy: " + IntegerToString(GetLastError()));
    Sleep(__SLEEP_AFTER_EXECUTION_FAIL);
    return(false);
    }

    return(true);
    }
    bool Sell(int MagicIndex, double Lots, int StopLossMethod, double StopLossPoints, int TakeProfitMethod, double TakeProfitPoints, int Slippage, int MaxOpenTrades,
    int MaxFrequencyMins, string TradeComment)
    {
    static double pipSize = 0;
    if(pipSize == 0) pipSize = Point * (1 + 9 * (Digits == 3 || Digits == 5));
    double sl = 0, tp = 0;
    double stopLossPoints = 0, takeProfitPoints = 0;
    int numberOfOpenTrades = 0;

    for(int i=OrdersTotal()-1;i>=0;i--){
    if(!OrderSelect(i, SELECT_BY_POS)) continue;
    if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != Symbol()) continue;
    numberOfOpenTrades ++;
    }
    if(MaxOpenTrades > 0 && numberOfOpenTrades >= MaxOpenTrades) return(false);

    if(MaxFrequencyMins > 0)
    {
    int recentSeconds = MaxFrequencyMins * 60;
    for(int i=OrdersTotal()-1;i>=0;i--){
    if(!OrderSelect(i, SELECT_BY_POS)) continue;
    if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != Symbol()) continue;
    if(TimeCurrent() - OrderOpenTime() < recentSeconds) return(false);
    }
    int hstTotal=OrdersHistoryTotal();

    for(int i=hstTotal-1;i>=0;i--)
    {
    if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) continue;
    if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != Symbol()) continue;
    if(TimeCurrent() - OrderOpenTime() < recentSeconds) return(false);
    break;
    }
    }

    if(Lots < MarketInfo(Symbol(),MODE_MINLOT)) return(false);

    if(AccountFreeMarginCheck(Symbol(), OP_SELL,Lots) <= 0) {
    Print("Sell order error: insufficient capital");
    return(false);
    }

    if (StopLossPoints > 0)
    {
    if(StopLossMethod == 0)
    {
    sl = NormalizeDouble(Bid + StopLossPoints * Point, Digits);
    stopLossPoints = StopLossPoints;
    }
    else if(StopLossMethod == 1)
    {
    sl = NormalizeDouble(Bid + StopLossPoints * pipSize, Digits);
    stopLossPoints = StopLossPoints * (1 + 9 * (Digits == 3 || Digits == 5));
    }
    else
    {
    sl = StopLossPoints;
    stopLossPoints = (sl - Bid)/Point;
    }
    }
    if (TakeProfitPoints > 0)
    {
    if(TakeProfitMethod == 0)
    {
    tp = NormalizeDouble(Bid - TakeProfitPoints * Point, Digits);
    takeProfitPoints = TakeProfitPoints;
    }
    else if (TakeProfitMethod == 1)
    {
    tp = NormalizeDouble(Bid - TakeProfitPoints * pipSize, Digits);
    takeProfitPoints = TakeProfitPoints * (1 + 9 * (Digits == 3 || Digits == 5));
    }
    else
    {
    tp = TakeProfitPoints;
    takeProfitPoints = (Bid - tp)/Point;
    }
    }

    double stopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL) + MarketInfo(Symbol(),MODE_SPREAD);

    if( (sl > 0 && stopLossPoints <= stopLevel) || (tp > 0 && takeProfitPoints <= stopLevel) )
    {
    Print("Cannot Sell: Stop loss and take profit must be at least "
    + DoubleToStr(MarketInfo(Symbol(),MODE_STOPLEVEL) + MarketInfo(Symbol(),MODE_SPREAD),0)
    + " points away from the current price");
    return (false);
    }

    RefreshRates();
    int result = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, sl, tp, "EA SELL " + "(" + WindowExpertName() + ") " + TradeComment,__STRATEGY_MAGIC + MagicIndex);
    if (result == -1){
    Print("Failed to Sell: " + IntegerToString(GetLastError()));
    Sleep(__SLEEP_AFTER_EXECUTION_FAIL);
    return(false);
    }

    return(true);
    }
     
  9. Erika889

    Erika889 Member Credit Hunter

    Equity
    Credit
    Ref Point
    Wadau...

    Ada group sharing edukasi coding yg bagus, coba join t.me/codeMQL
    Banyak contoh dan respon yang aktif disana.
     
  10. akocha

    akocha New Member

    Equity
    Credit
    Ref Point
    5/5,
    This is my review for this thread:
    mantap... makasih Suhu
     
  11. NUBEFX

    NUBEFX New Member

    Equity
    Credit
    Ref Point
    suhu ada materi mengenai insert news filter ke ea gak ya,,. atau code custom indi ke dalam ea,.,.


    thanks alot.,
     

Share This Page