Forex Community Place

Dapatkan hingga
$50000
karena mengundang teman
untuk memperoleh Bonus StartUp
dari InstaForex
Tidak perlu investasi!
Mulai trading tanpa
risiko dan investasi
Dengan Bonus Permulaan 1000$
Dapatkan bonus
55%
ke akun anda!
Results 1 to 2 of 2

Thread: [ASK] indikator multi order sell / buy mq5

  1. #1
    Newbie
    ----
     
    ar135_p is on a distinguished road ar135_p's Avatar
    Join Date
    May 2013
    Posts
    44
    Accumulated bonus
    0 USD (What is this?)
    Thanks
    21
    Thanked 42 Times in 14 Posts

    [ASK] indikator multi order sell / buy mq5

    MAlam,

    Ada yang punya script MT5 untuk sekali klik 5 order baik sell/buy, yang didalamnya ada SL, TP, besaran lot ? Juga close all order nya.

    Untuk MT4 sih saya sudah punya.

    Terima kasih

    update: untuk yang close all baru dapat dan sudah dicoba ok. Yang belum untuk open posisi.
    Last edited by ar135_p; 04-03-2019 at 19:23. Reason: baru ketemu yang close orer

  2. FB_indo
  3. #2
    Orang Lama
    Semilir
     
    amtwoxtwo is a name known to all amtwoxtwo is a name known to all amtwoxtwo is a name known to all amtwoxtwo is a name known to all amtwoxtwo is a name known to all amtwoxtwo is a name known to all amtwoxtwo's Avatar
    Join Date
    Sep 2010
    Location
    Sekitaran Bumi
    Posts
    1,049
    Accumulated bonus
    139 USD (What is this?)
    Thanks
    96
    Thanked 605 Times in 309 Posts
    Quote Originally Posted by ar135_p     
    MAlam,

    Ada yang punya script MT5 untuk sekali klik 5 order baik sell/buy, yang didalamnya ada SL, TP, besaran lot ? Juga close all order nya.

    Untuk MT4 sih saya sudah punya.

    Terima kasih

    update: untuk yang close all baru dapat dan sudah dicoba ok. Yang belum untuk open posisi.
    Code:
    // exported variables
    input double Lots = 0.1;
    input int Stoploss = 20;
    input int Takeprofit = 30;
    input int ExecuteCount = 5;
    
    
    // local variables
    double PipValue=1;    // this variable is here to support 5-digit brokers
    bool Terminated = false;
    string LF = "\n";  // use this in custom or utility blocks where you need line feeds
    int NDigits = 4;   // used mostly for NormalizeDouble in Flex type blocks
    int ObjCount = 0;  // count of all objects created on the chart, allows creation of objects with unique names
    int current = 0;
    
    
    //+------------------------------------------------------------------+
    //| Expert initialization function                                   |
    //+------------------------------------------------------------------+
    int OnInit()
    {
        //---
        NDigits = Digits();
        if (NDigits == 3 || NDigits == 5) PipValue = 10;
        
        if (AccountInfoInteger(ACCOUNT_TRADE_EXPERT) == false)
        {
            Print("Check terminal options because EA trade option is set to not allowed.");
            Comment("Check terminal options because EA trade option is set to not allowed.");
        }
        
        if (false) ObjectsDeleteAll(0);      // clear the chart
        
        
        Comment("");    // clear the chart
        //---
        return(0);
    }
    //+------------------------------------------------------------------+
    //| Expert deinitialization function                                 |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
    {
        //---
        if (false) ObjectsDeleteAll(0);
        
        
        return;
    }
    //+------------------------------------------------------------------+
    //| Expert tick function                                             |
    //+------------------------------------------------------------------+
    void OnTick()
    {
        //---
        if (Terminated == true)
        {
            Comment("EA Terminated.");
        }
        
        OnEveryTick1();
        return;
    }
    
    //+------------------------------------------------------------------+
    //| Get Low for specified bar index                                  |
    //+------------------------------------------------------------------+
    double Low(int index)
    {
        double arr[];
        double low = 0;
        ArraySetAsSeries(arr, true);
        int copied = CopyLow(Symbol(), PERIOD_CURRENT, 0, Bars(Symbol(), PERIOD_CURRENT), arr);
        if (copied>0 && index<copied) low = arr[index];
        return (low);
    }
    //+------------------------------------------------------------------+
    //| Get the High for specified bar index                             |
    //+------------------------------------------------------------------+
    double High(int index)
    {
        double arr[];
        double high = 0;
        ArraySetAsSeries(arr, true);
        int copied = CopyHigh(Symbol(), PERIOD_CURRENT, 0, Bars(Symbol(), PERIOD_CURRENT), arr);
        if (copied>0 && index<copied) high=arr[index];
        return(high);
    }
    //+------------------------------------------------------------------+
    //| Get Close for specified bar index                                |
    //+------------------------------------------------------------------+
    double Close(int index)
    {
        double arr[];
        double close = 0;
        ArraySetAsSeries(arr, true);
        int copied = CopyClose(Symbol(), PERIOD_CURRENT, 0, Bars(Symbol(), PERIOD_CURRENT), arr);
        if (copied>0 && index<copied) close = arr[index];
        return (close);
    }
    //+------------------------------------------------------------------+
    //| Get Open for specified bar index                                 |
    //+------------------------------------------------------------------+
    double Open(int index)
    {
        double arr[];
        double open = 0;
        ArraySetAsSeries(arr, true);
        int copied = CopyOpen(Symbol(), PERIOD_CURRENT, 0, Bars(Symbol(), PERIOD_CURRENT), arr);
        if (copied>0 && index<copied) open = arr[index];
        return (open);
    }
    //+------------------------------------------------------------------+
    //| Get current bid value                                            |
    //+------------------------------------------------------------------+
    double Bid()
    {
        return (SymbolInfoDouble(Symbol(), SYMBOL_BID));
    }
    
    //+------------------------------------------------------------------+
    //| Get current ask value                                            |
    //+------------------------------------------------------------------+
    double Ask()
    {
        return (SymbolInfoDouble(Symbol(), SYMBOL_ASK));
    }
    
    //+------------------------------------------------------------------+
    //| Is there an error                                                |
    //+------------------------------------------------------------------+
    bool IsError(MqlTradeResult& result, string function)
    {
        if (result.retcode != 0 && result.retcode != TRADE_RETCODE_DONE && result.retcode != TRADE_RETCODE_PLACED)
        {
            Print("Function: ", function, " Error: ", result.retcode, " ", result.comment);
            return (true);
        }
        else
        Print("> Executed: [", function, "]");
        return (false);
    }
    
    bool IsError(CTrade& trade, string function)
    {
        if (trade.ResultRetcode() != 0 && trade.ResultRetcode() != TRADE_RETCODE_DONE && trade.ResultRetcode() != TRADE_RETCODE_PLACED)
        {
            Print("Function: ", function, " Error: ", trade.ResultRetcode(), " ", trade.ResultRetcodeDescription());
            return (true);
        }
        else
        Print("> Executed: [", function, "]");
        return (false);
    }
    
    //+------------------------------------------------------------------+
    //| Get indicator value back                                         |
    //+------------------------------------------------------------------+
    double GetIndicator(int handle, int buffer_num, int index)
    {
        //--- array for the indicator values
        double arr[];
        //--- obtain the indicator value in the last two bars
        if (CopyBuffer(handle, buffer_num, 0, index+1, arr) <= 0)
        {
            Sleep(200);
            for(int i=0; i<100; i++)
            {
                if (BarsCalculated(handle) > 0)
                break;
                Sleep(50);
            }
            int copied = CopyBuffer(handle, buffer_num, 0, index+1, arr);
            if (copied <= 0)
            {
                Print("CopyBuffer failed. Maybe history has not download yet? Error = ", GetLastError());
                return -1;
            }
            else
            return (arr[index]);
        }
        else
        {
            return (arr[index]);
        }
        
        return 0;
    }
    
    void OnEveryTick()
    {
        
        if (NDigits == 3 || NDigits == 5) PipValue = 10;
        
        ExecuteNTimes();
        
    }
    
    void ExecuteNTimes()
    {
        if (ExecuteCount > 0)
        {
            ExecuteCount--;
            BuyOrder();
            
        }
    }
    
    void BuyOrder()
    {
        
        //--- prepare a request
        MqlTradeRequest request;
        ZeroMemory(request);
        request.action = TRADE_ACTION_DEAL;          // setting a deal order
        request.magic = 1;                   // ORDER_MAGIC
        request.symbol = Symbol();                   // symbol
        request.volume= Lots;                      // volume in lots
        request.price = Ask();
        request.sl = Ask() - Stoploss*PipValue*Point();      // Stop Loss specified
        request.tp = Ask() + Takeprofit*PipValue*Point();    // Take Profit specified
        request.deviation= 4;             // deviation in points
        request.type = ORDER_TYPE_BUY;
        request.comment = "Order";
        MqlTradeResult result;
        ZeroMemory(result);
        bool ok = OrderSend(request,result);
        // check the result
        if (ok && !IsError(result, __FUNCTION__))
        {
                
        }
        
        
    }
    buy sejumlah x kali. tinggal ubah parameter ExecuteCount.
    kalo mau yang sell, code dibawah.
    Code:
    void SellOrder()
    {
        
        //--- prepare a request
        MqlTradeRequest request;
        ZeroMemory(request);
        
        request.action = TRADE_ACTION_DEAL;          // setting a deal order
        request.magic = 1;                   // ORDER_MAGIC
        request.symbol = Symbol();                   // symbol
        request.volume = Lots2;                      // volume in lots
        request.price = Bid();
        request.sl = Bid() + Stoploss2*PipValue*Point();      // Stop Loss specified
        request.tp = Bid() - Takeprofit2*PipValue*Point();    // Take Profit specified
        request.deviation = 4;             // deviation in points
        request.type = ORDER_TYPE_SELL;
        request.comment = "Order";
        MqlTradeResult result;
        ZeroMemory(result);
        bool ok = OrderSend(request,result);
        // check the result
        if (ok && !IsError(result, __FUNCTION__))
        {
                
        }
        
        
    }
    Yahuuu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts