• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 1:44pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 1:44pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

EA "Close all positions at profit target" closed all positions at loss ? 8 replies

Close All Positions MT4 4 replies

Mt4 Close Profit positions before Market closed on weekend? 1 reply

ibfx live script to close all positions 6 replies

Help for Script to close all open positions 4 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 10
Attachments: Is it possible to close all positions on mt4?
Exit Attachments

Is it possible to close all positions on mt4?

  • Last Post
  •  
  • 1 Page 2 3
  • 1 Page 2 3
  •  
  • Post #21
  • Quote
  • Jun 11, 2013 1:56am Jun 11, 2013 1:56am
  •  ymleong
  • | Commercial Member | Joined Jun 2013 | 120 Posts
Quoting CodersGuru
Disliked
Here's my CloseAll script (Version 2.01 - 22-July-2011) // Set the optoin prameter to the type of clsoing you want: // 0- Close all (instant and pending orders) (Default) // 1- Close all instant orders // 2- Close all pending orders // 3- Close by the magic number // 4- Close by comment // 5- Close orders in profit // 6- Close orders in loss // 7- Close not today orders // 8- Close before day orders {file}
Ignored
Hi, I wanted to close all OPEN positions once a certain P/l ($) is reached or once a certain pips is reached or once a certain % of profits in relation to account balance (Total pips or Total profits of Open Trades).

For 1st option, eg pips=1000 (so script will close ALL opened trades when TOTAL pips=>1000pips)
2nd option, eg profit=$500 (script will close ALL opened trades when TOTAL P/L$ for these trades => $500)
3rd option, eg, profit%=2. Calculation is each trade P/L ($)/account balance/100. Thus when trade's P/L=$100 and acct balance = $5000, thats 2%, so close this trade. The script will just go thru each and every open trade and close it automatically. Its become an EA but just doesnt trade
 
 
  • Post #22
  • Quote
  • Sep 10, 2013 3:02pm Sep 10, 2013 3:02pm
  •  rahi1
  • | Joined Sep 2013 | Status: Junior Member | 2 Posts
As far as I know, there is no such thing as instant closing on Meta 4. The script or EA will place all trades in to a que and execute them on their turn. The orders will get closed but not instantly and it may be that by the time all open positions closed, you may have partial profit or a l loss at the end of closing process.
 
 
  • Post #23
  • Quote
  • Sep 11, 2013 10:24am Sep 11, 2013 10:24am
  •  akukaya
  • | Commercial Member | Joined Jul 2008 | 567 Posts
Quoting rahi1
Disliked
As far as I know, there is no such thing as instant closing on Meta 4. The script or EA will place all trades in to a que and execute them on their turn. The orders will get closed but not instantly and it may be that by the time all open positions closed, you may have partial profit or a l loss at the end of closing process.
Ignored

Rahi, I believe so.

Do you know if I have 10 open trades, and want to close all, which option will close all of them faster?
1. Use CloseAll script or EA
or
2. Set all trades to have same SL target or TP target?

best rgds,
 
 
  • Post #24
  • Quote
  • Sep 13, 2013 8:44pm Sep 13, 2013 8:44pm
  •  rahi1
  • | Joined Sep 2013 | Status: Junior Member | 2 Posts
Setting up SL and TP Targets of all trades will give you an advantage of the hard close option. While using EA to close will have a limit order application and on Market hit will be an open order. If you only have 10 orders to worry, then the execution time may not differ significantly, but the use of SL and TP will definately give you the asking price. Have you ever though of using API ? API will have a low latency rate compare to Framed Meta 4 order flow.

Regards,

Rahi1
 
 
  • Post #25
  • Quote
  • Feb 12, 2015 7:50pm Feb 12, 2015 7:50pm
  •  Jane27
  • | Joined Feb 2015 | Status: Junior Member | 1 Post
Hi everyone,
I have a problem closing all position by the click of the button I've created. Can someone please help 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;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUY)
{
close=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),3,Green);
RefreshRates();
}
if(OrderType()==OP_SELL)
{
close=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),3,Green);
RefreshRates();
i=0;
}

}
Thank you!
Jane
 
 
  • Post #26
  • Quote
  • Feb 13, 2015 7:10am Feb 13, 2015 7:10am
  •  Praetor
  • | Joined Oct 2014 | Status: Member | 36 Posts
Can somebody pse help me with the following ea, when i drag it onto the chart, nothing happens:

{
OrderSelect(cc,SELECT_BY_POS);
if ({TimeCurrent() - OrderOpenTime() >= (TradesWillExpireMins*60)} && OrderMagicNumber()==MagicNumber) - THIS IS THE LINE 1529 with the ERROR
{
if (ShowAlerts) Alert("Trade expiry time has been reached, so a;; baslet trades were closed");
CloseBasket=true;//This will force basket trade closure on the next tick
return;
}

ERROR message when I compiled it:


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

thank you
 
 
  • Post #27
  • Quote
  • Feb 13, 2015 7:48am Feb 13, 2015 7:48am
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Inserted Code
if ({TimeCurrent() - OrderOpenTime() >= (TradesWillExpireMins*60)} && OrderMagicNumber()==MagicNumber)

Why do you have the {} in there. removing them may help
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #28
  • Quote
  • Feb 15, 2015 12:32am Feb 15, 2015 12:32am
  •  Praetor
  • | Joined Oct 2014 | Status: Member | 36 Posts
Quoting Gumrai
Disliked
if ({TimeCurrent() - OrderOpenTime() >= (TradesWillExpireMins*60)} && OrderMagicNumber()==MagicNumber) Why do you have the {} in there. removing them may help
Ignored

thanks Gumrai, that worked, appreciate your quick response.
 
 
  • Post #29
  • Quote
  • Mar 23, 2015 11:58am Mar 23, 2015 11:58am
  •  StOoOk
  • | Joined Aug 2014 | Status: Member | 343 Posts
Quoting bodisatva
Disliked
the best 1 simply double click on the script when u wanna close {file} {file}
Ignored
thank you
if there is market there will be opportunities
 
 
  • Post #30
  • Quote
  • Apr 3, 2015 11:32am Apr 3, 2015 11:32am
  •  wakeel86
  • | Joined Dec 2011 | Status: Member | 148 Posts
Can anyone help code a script that closes trades (live and pending) of specified pairs only (pair set on script properties) without interfering with trades of other pairs

Also, another script that closes
-buy trades only (live and pending)
-sell trades only (live and pending)
 
 
  • Post #31
  • Quote
  • Aug 5, 2015 6:05am Aug 5, 2015 6:05am
  •  holdocu82
  • | Joined Aug 2015 | Status: Member | 18 Posts
Hey guys. I have been searching a similar script for few weeks and could not be able to find exactly what I want.

I want a script(or whatever) to close my all open orders (buy and sell together or can be set one or other) and my pending orders WHEN the PRICE hits a certain target which i set like 1.09500.

I found some scripts doing what I want with target pips or profit targets but none of them was triggered with the price itself.

I hope someone knows how to do it. Thank you for helping.
 
 
  • Post #32
  • Quote
  • Aug 5, 2015 7:27am Aug 5, 2015 7:27am
  •  grrbear
  • | Membership Revoked | Joined Oct 2013 | 465 Posts
Quoting holdocu82
Disliked
Hey guys. I have been searching a similar script for few weeks and could not be able to find exactly what I want. I want a script(or whatever) to close my all open orders (buy and sell together or can be set one or other) and my pending orders WHEN the PRICE hits a certain target which i set like 1.09500. I found some scripts doing what I want with target pips or profit targets but none of them was triggered with the price itself. I hope someone knows how to do it. Thank you for helping.
Ignored
http://www.forexfactory.com/showthre...77#post8414777

with this ea you specify a signal pair and exit price and the ea will close trades when that price is reached. not sure if it will work globally, if not then make sure to use magic numbers that are the same as magic numbers used in ea
 
 
  • Post #33
  • Quote
  • Aug 5, 2015 10:54am Aug 5, 2015 10:54am
  •  holdocu82
  • | Joined Aug 2015 | Status: Member | 18 Posts
Quoting grrbear
Disliked
{quote} http://www.forexfactory.com/showthre...77#post8414777 with this ea you specify a signal pair and exit price and the ea will close trades when that price is reached. not sure if it will work globally, if not then make sure to use magic numbers that are the same as magic numbers used in ea
Ignored
The .ex4 file on that topic does not respond. I installed it like other indicators, when I add it in the chart nothing happens. Am I doing something wrong or its broken?
 
 
  • Post #34
  • Quote
  • Aug 5, 2015 11:25am Aug 5, 2015 11:25am
  •  grrbear
  • | Membership Revoked | Joined Oct 2013 | 465 Posts
Quoting holdocu82
Disliked
{quote} The .ex4 file on that topic does not respond. I installed it like other indicators, when I add it in the chart nothing happens. Am I doing something wrong or its broken?
Ignored
did you put it in the experts folder?
 
 
  • Post #35
  • Quote
  • Aug 5, 2015 12:26pm Aug 5, 2015 12:26pm
  •  holdocu82
  • | Joined Aug 2015 | Status: Member | 18 Posts
Quoting grrbear
Disliked
{quote} did you put it in the experts folder?
Ignored
Ohh I placed it to indicators folder thats why it didnt work. Now its ok but which value is the kill value of all trades grrbear?
 
 
  • Post #36
  • Quote
  • Aug 6, 2015 6:44am Aug 6, 2015 6:44am
  •  francmorio
  • | Membership Revoked | Joined May 2013 | 553 Posts
Thank you so much for the indicator, let me try if it works out. Thanks
 
 
  • Post #37
  • Quote
  • Aug 6, 2015 10:40am Aug 6, 2015 10:40am
  •  holdocu82
  • | Joined Aug 2015 | Status: Member | 18 Posts
Quoting francmorio
Disliked
Thank you so much for the indicator, let me try if it works out. Thanks
Ignored
I tested it, and works fine but I need the trigger to be the PRICE not profit.
 
 
  • Post #38
  • Quote
  • Aug 6, 2015 11:59am Aug 6, 2015 11:59am
  •  grrbear
  • | Membership Revoked | Joined Oct 2013 | 465 Posts
Quoting holdocu82
Disliked
{quote} I tested it, and works fine but I need the trigger to be the PRICE not profit.
Ignored
choose EURUSD as signal pair and 1.08876 as the exit price and all pairs will be closed when eurusd reaches that price. maybe it only closes trades with same magic number i'm not sure
 
 
  • View Post
  • Hidden for breach of Trader Code of Conduct
  • francmorio
  • Post #40
  • Quote
  • Mar 6, 2016 6:54am Mar 6, 2016 6:54am
  •  GoopFX
  • | Commercial Member | Joined Feb 2016 | 43 Posts
hi guys, i am looking for way to close all trades open. (without dependent on "autotrading" setting on mt4. Is there a way? because i run some trading EAs which require me to keep autotrading open. So i am thinking may be someone can create script on "chart" perhaps a one click-thru button type where i click n all trades get closed within seconds. is this possible? thanks
 
 
  • Platform Tech
  • /
  • Is it possible to close all positions on mt4?
  • Reply to Thread
    • 1 Page 2 3
    • 1 Page 2 3
0 traders viewing now
  • More
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2022