Is it possible to close all positions on mt4?
1 2 3 ...

thread: Is it possible to close all positions on mt4?

  1. #1
    Junior Member Lotfi_jbilou's Avatar
    1

    Is it possible to close all positions on mt4?

    Something like script or ea...

  2. #2
    Junior Member alexmolvi's Avatar
    1
    Here is my CloseAll script (Model 2.01 - 22-July-2011) // Establish the optoin prameter to the type of clsoing you need: // 0- Close all (instant and pending orders) (Default) // 1- Close all instant orders // 2- Close all pending orders // 3- Close from the magical number // 4- Close by remark // 5- Close orders in profit // 6- Close orders in loss // 7- Close not today orders // 8- Close before day orders file
    Hello, I wanted to shut all OPEN positions after a certain P/l ($) is reached or after a certain pips is reached or after a certain% of profits concerning account balance (Total pips or Total profits of Open Trades).

    For 1st alternative, eg pips=1000 (so script will shut ALL opened transactions if TOTAL pips=gt;1000pips)
    2nd alternative, eg profit=$500 (script will shut ALL opened transactions once TOTAL P/L$ for these transactions =gt; $500)
    3rd alternative, eg, profitpercent =2. Calculation is every transaction P/L ($)/account balance/100. When trade's P/L=$100 and balance = $5000, thats 2%, so that transaction. The script will go thru each and every trade and close it automatically. Its turned into an EA but just doesnt trade

  3. #3
    Junior Member berpklo's Avatar
    2
    So far as I know, there is no such thing as shutting on Meta 4. EA or the script will place all trades in to a que and implement them. The orders will probably get closed but not instantly and it may be that by now all open positions closed, you may have partial profit or even a loss .

  4. #4
    Member
    71
    As far as I know, there's absolutely no such thing as instantaneous shutting on Meta 4. The script or EA will put all trades into a que and execute them in their turn. The orders will probably get closed but not instantly and it might be that all open positions closed, you might have partial profit or even a l loss .
    Rahi, I believe so.

    Can you understand if I have 10 open trades, and want to shut all, which choice will close all of them faster?
    1. Use CloseAll script or EA
    or
    2. Set all trades to have TP goal or SL goal?

    best rgds,

  5. #5
    Junior Member berpklo's Avatar
    2
    Setting up TP and SL Targets of trades will give you an advantage of the close option. When using EA to shut will have a limit order appliion and also on Market strike will probably likely be an open order. If you only have 10 orders to stress, then the implementation period may not differ significantly, but the usage of SL and TP will give you the asking price. Have you ever thought of using API? API will have a minimal latency rate compare to Framed Meta 4 order flow.

    Regards,

    Rahi1

  6. #6
    Junior Member morgan40's Avatar
    1
    Hello everybody,
    I've a problem closing all place by the click of the button I have created. Can somebody please assist me?
    I just started coding... Here is what I have:

    NABtnState=ObjectGet(BtnCloseAll,OBJPROP_STATE);
    bool close;
    if(ObjectGet(btnCloseAll,OBJPROP_STATE))
    {
    ObjectSet(btnCloseAll,OBJPROP_STATE,0);

    for(int I=OrdersTotal()-1;igt;=0;I--)

    OrderSelect(I,SELECT_BY_POS,MODE_TRADES);
    if(OrderType()==OP_BUY)

    near =OrderClose(OrderTicket(),OrderLots(),MarketInfo(O rderSymbol(),MODE_BID),3,Green);
    RefreshRates();

    if(OrderType()==OP_SELL)

    near =OrderClose(OrderTicket(),OrderLots(),MarketInfo(O rderSymbol(),MODE_ASK),3,Green);
    RefreshRates();
    I=0;



    Thanks!
    Jane

  7. #7
    Junior Member Oxyte.'s Avatar
    3
    Can somebody pse help me with the following ea, when I drag it on the chart, nothing happens:

    {
    OrderSelect(cc,SELECT_BY_POS);
    if (TimeCurrent() - OrderOpenTime() gt;= (TradesWillExpireMins*60) OrderMagicNumber()==MagicNumber) - THIS IS THE LINE 1529 Together with the ERROR

    if (ShowAlerts) Alert(Trade expiry time has been reached, Therefore a;; baslet Transactions were closed);
    CloseBasket=true;//This will force basket trade Closing on Another tick
    return;


    ERROR message when I compiled it


    1.'TimeCurrent' - constant expression demanded Multi purpose trade manager.mq4 1529 15
    2.' {' - unexpected token Multi purpose trade manager.mq4 1529 14

    thank you

  8. #8
    Inserted Code if (TimeCurrent() - OrderOpenTime() gt;= (TradesWillExpireMins*60) OrderMagicNumber()==MagicNumber)
    Why do you possess the {} in there. Removing them may help

  9. #9
    Junior Member Oxyte.'s Avatar
    3
    if (TimeCurrent() - OrderOpenTime() gt;= (TradesWillExpireMins*60) OrderMagicNumber()==MagicNumber) why is it that you have the {} in there. Eliminating them may help
    thanks Gumrai, that functioned, appreciate your quick response.

  10. #10
    Junior Member surfcasting67's Avatar
    1
    the Top 1 simply double Click the script If u wanT Shut file file
    thank you

  •