1. 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

Coding BUY SELL di Button

Discussion in 'Belajar MQL dari Nol' started by Aries Sekawan, 24 Jul 2020.

  1. Aries Sekawan

    Aries Sekawan New Member

    Equity
    Credit
    Ref Point
    halo para guru,,,
    saya sudah belajar buat coding Button BUY, SELL dan CLOSE.
    Bisa Tolong di bantu buatin Fungsinya ga guru,,,
    Uda coba googling, tapi ga ketemu.
    Code:
    #property copyright "Copyright 2020, MetaQuotes Software Corp."
    #property link      "https://www.mql5.com"
    #property version   "1.00"
    #property strict
    #define BUTTON_CLOSE "Button Close"
    #define BUTTON_BUY   "Button Buy"
    #define BUTTON_SELL  "Button Sell"
    
    
    
    //+------------------------------------------------------------------+
    //| Expert initialization function                                   |
    //+------------------------------------------------------------------+
    int OnInit()
      {
    //---
       
       ObjectCreate      (0,BUTTON_CLOSE,OBJ_BUTTON,0,0,0);
       ObjectSetInteger  (0,BUTTON_CLOSE,OBJPROP_XSIZE,50);
       ObjectSetInteger  (0,BUTTON_CLOSE,OBJPROP_YSIZE,25);
       ObjectSetInteger  (0,BUTTON_CLOSE,OBJPROP_XDISTANCE,10);
       ObjectSetInteger  (0,BUTTON_CLOSE,OBJPROP_YDISTANCE,15);
       ObjectSetInteger  (0,BUTTON_CLOSE,OBJPROP_COLOR,clrWhite);
       ObjectSetInteger  (0,BUTTON_CLOSE,OBJPROP_BGCOLOR,clrGold);
       ObjectSetString   (0,BUTTON_CLOSE,OBJPROP_TEXT,"CLOSE");
       
       ObjectCreate      (0,BUTTON_BUY,OBJ_BUTTON,0,0,0);
       ObjectSetInteger  (0,BUTTON_BUY,OBJPROP_XSIZE,50);
       ObjectSetInteger  (0,BUTTON_BUY,OBJPROP_YSIZE,25);
       ObjectSetInteger  (0,BUTTON_BUY,OBJPROP_XDISTANCE,70);
       ObjectSetInteger  (0,BUTTON_BUY,OBJPROP_YDISTANCE,15);
       ObjectSetInteger  (0,BUTTON_BUY,OBJPROP_COLOR,clrWhite);
       ObjectSetInteger  (0,BUTTON_BUY,OBJPROP_BGCOLOR,clrBlue);
       ObjectSetString   (0,BUTTON_BUY,OBJPROP_TEXT,"BUY");
       
       ObjectCreate      (0,BUTTON_SELL,OBJ_BUTTON,0,0,0);
       ObjectSetInteger  (0,BUTTON_SELL,OBJPROP_XSIZE,50);
       ObjectSetInteger  (0,BUTTON_SELL,OBJPROP_YSIZE,25);
       ObjectSetInteger  (0,BUTTON_SELL,OBJPROP_XDISTANCE,130);
       ObjectSetInteger  (0,BUTTON_SELL,OBJPROP_YDISTANCE,15);
       ObjectSetInteger  (0,BUTTON_SELL,OBJPROP_COLOR,clrWhite);
       ObjectSetInteger  (0,BUTTON_SELL,OBJPROP_BGCOLOR,clrRed);
       ObjectSetString   (0,BUTTON_SELL,OBJPROP_TEXT,"SELL");
       
       
    //---
       return(INIT_SUCCEEDED);
      }
    //+------------------------------------------------------------------+
    //| Expert deinitialization function                                 |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
      {
    //---
       
      }
    //+------------------------------------------------------------------+
    //| Expert tick function                                             |
    //+------------------------------------------------------------------+
    void OnTick()
      {
    //---
       }
     
    • Like Like x 1
  2. Onyx MIB

    Onyx MIB Member

    Equity
    Credit
    Ref Point
    tambahkan event-handle: OnEventChart()
    di dalam fungsi event itu,
    kamu bisa coding utk hadle object BUY/SELL, dll.

    Contoh ya:

    Code:
    void OnChartEvent(const int id,
                   const long &lparam,
                   const double &dparam,
                   const string &sparam)
    {
    //---
       if (id == CHARTEVENT_OBJECT_CLICK){
          int orderType = -1;
          if (sparam == "BUTTON_BUY"){
             Print ("Open BUY");
             //Disini bisa lanjutkan dengan code untuk open order BUY
    
          }else if (sparam == "BUTTON_SELL"){
             Print ("Open SELL");
          }
         
       }
    }
    //+------------------------------------------------------------------+
    
    Silakan gabung di group belajar code MQL di https:/t.me/codeMQL
     
    • Winner Winner x 1
  3. acin acin

    acin acin Member Credit Hunter

    Equity
    Credit
    Ref Point
    5/5,
    This is my review for this thread:
    thread yang bermanfaat
     

Share This Page