Торговые платформы, обслуживание и поддержка » Broco Trader (MetaTrader 4) » Help: close position script for broco trader 4.0 and broco investor
+ Подписаться
  1. 52
    Комментарии
    10
    Темы
    54
    Репутация Pro
     
    В начале пути

    4 Медалей

    Help: close position script for broco trader 4.0 and broco investor

    Hello,

    for other brokers like IBFX,FXDD I can use this script below as they are using instant execution

    I tried this script on broco trader but not working,I'm no programmer so I wonder what shoudl I change on this script to make it working?

    I would like to make this script hot keys

    that is to say e.g Ctrl + c ---> a market order will execute to close position

    thanks for helping

    Код:
    //+------------------------------------------------------------------+
    //|                                                    CLOSE_ALL.mq4 |
    //|                                                             pileo|
    //|                                        http://www.metaquotes.net |
    //+------------------------------------------------------------------+
    #property copyright "pileo"
    #property link      "http://www.metaquotes.net"
    
    #include <stdlib.mqh>
    #include <WinUser32.mqh>
    //+------------------------------------------------------------------+
    //| script program start function                                    |
    //+------------------------------------------------------------------+
    int start()
      {
    //---- 
       if(MessageBox("Do you really want to close all positions?", "Close All", MB_YESNO|MB_ICONQUESTION) !=IDYES) return(1);
     
       double prc;
       int prc_mode;
         
       int total = OrdersTotal();
       int orders[];
       
       int size;
       size = ArrayResize(orders, total);
       
       //Get original positions
       for(int i=0;i<total;i++)
       {
          OrderSelect(i, SELECT_BY_POS);
          orders[i] = OrderTicket();
       }
       
       if(size <= 0)
       {
          //No open orders
          return(-1);
       }
    
    
       int ticketSent;   
       for(int x=0;x<size;x++)
       {
          OrderSelect(orders[x], SELECT_BY_TICKET);
          
          if(OrderType()==OP_BUY)
             prc_mode = MODE_BID; 
          else
             prc_mode = MODE_ASK;
             
          prc = MarketInfo(OrderSymbol(), prc_mode);
          
          Print("Closing Order # ", orders[x], " symbol: ", OrderSymbol(), " price: ", prc);
          
          if(OrderClose(orders[x],OrderLots(),prc,3))
          {
             Print("Order # ", orders[x], " closed");
          }
          else
          {
             Print("Failed to close Order # ", orders[x], " Error: ", GetLastError());
             return(false);
          }
       }
    
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    Недоступно! Pro 0
    Поделиться
    Просмотров: 7,094
  2. 381
    Комментарии
    8
    Темы
    381
    Репутация Pro
     
    Сотрудник компании

    3 Медалей
    Your script work correct.
    Please, check, that you enable script to work.
    Menu -> Tools -> Options, tab "Expert Advisors".
    Select:
    1) "Enable Expert Advisors"
    2) "Allow live trading".
  3. 52
    Комментарии
    10
    Темы
    54
    Репутация Pro
     
    В начале пути

    4 Медалей
    Цитата Сообщение от Сергей Жуков Посмотреть сообщение
    Your script work correct.
    Please, check, that you enable script to work.
    Menu -> Tools -> Options, tab "Expert Advisors".
    Select:
    1) "Enable Expert Advisors"
    2) "Allow live trading".
    thanks

    Do you have any idea how do I remove this?



    actually I would like to use it for fast open/close position with 1 click dealing @ scalping...if you do have any useful tool please share...

    thanks :bow:

    to open position F9 - Great

    closing position = no hotkeys - bad
  4. 52
    Комментарии
    10
    Темы
    54
    Репутация Pro
     
    В начале пути

    4 Медалей
    nevermind found it
  5. 381
    Комментарии
    8
    Темы
    381
    Репутация Pro
     
    Сотрудник компании

    3 Медалей
    1)
    Цитата Сообщение от hanz Посмотреть сообщение
    thanks

    Do you have any idea how do I remove this?

    Comment string
    Код:
     // if(MessageBox("Do you really want to close all positions?", "Close All", MB_YESNO|MB_ICONQUESTION) !=IDYES) return(1);
    2)
    Цитата Сообщение от hanz Посмотреть сообщение
    closing position = no hotkeys - bad
    I rename your listing as "listing.mq4"
    At first step

    Then

    -------------
    Welcome on our forum. :D
  6. 52
    Комментарии
    10
    Темы
    54
    Репутация Pro
     
    В начале пути

    4 Медалей
    Hi,

    as you might already know not seldom brokers using metatrader's market execution most of them are using instant execution which may comes to requote...

    I have search the internet but failed to find any script to make market orders

    I already have a close position script to close my position using hotkeys

    not I'm looking for buy and sell market script

    it would be great if someone share it here

    say hotkeys for buy market CTRL + A

    sell market CTRL + S

    close market or close position CTRL + X

    thanks! :bow:
  7. 381
    Комментарии
    8
    Темы
    381
    Репутация Pro
     
    Сотрудник компании

    3 Медалей
    hanz, please read instruction how set hotkey for script
    http://www.procapital.ru/showthread.php?t=14610
    Attach
    buy_market.mq4 - script for buy
    sell_market.mq4 - script for sell
    close_all.mq4 - script close all orders (get script from link)
    -----
    Вложения Вложения

Вверх
РегистрацияX

чтобы писать, читать, комментировать