spike123 Posted September 25, 2009 Report Share Posted September 25, 2009 Hello, how could i close all orders that are running with one klick. Only with the MT4 Platform? Right click somewhere or so? Pls its important! Thanks a lot! Quote Link to comment Share on other sites More sharing options...
dr0o69 Posted September 25, 2009 Report Share Posted September 25, 2009 (edited) Re: How to close all orders in MT4 ?!?! Imprtant!! thank you indo-investasi... now i become a better trader... Edited August 7, 2010 by dr0o69 Quote To know and not to do is not yet to know - Zen Link to comment Share on other sites More sharing options...
Phoenix1713006089 Posted September 27, 2009 Report Share Posted September 27, 2009 Re: How to close all orders in MT4 ?!?! Imprtant!! use this script */ #property copyright "" #property link "" extern int option = 0; extern bool BySymbolOnly = FALSE; extern int magic_number = 0; extern string comment_text = ""; extern int MaxNumberOfTries = 10; int g_count_100; int start() { CloseAll(); return (0); } int CloseAll() { int l_ord_total_0 = OrdersTotal(); int l_count_4 = 0; RefreshRates(); switch (option) { case 0: g_count_100 = 0; while (CountOpenTrades(BySymbolOnly, 1) > 0 && g_count_100 < MaxNumberOfTries) { CloseAllTrades(BySymbolOnly, 1); RefreshRates(); Sleep(1000); g_count_100++; } break; case 1: g_count_100 = 0; while (CountOpenTrades(BySymbolOnly, 0) > 0 && g_count_100 < MaxNumberOfTries) { CloseAllTrades(BySymbolOnly, 0); RefreshRates(); Sleep(1000); g_count_100++; } break; case 2: g_count_100 = 0; while (CountPending(BySymbolOnly) > 0 && g_count_100 < MaxNumberOfTries) { CloseAllPending(BySymbolOnly); Sleep(1000); g_count_100++; } break; case 3: for (l_count_4 = 0; l_count_4 <= l_ord_total_0; l_count_4++) { OrderSelect(0, SELECT_BY_POS, MODE_TRADES); if (OrderMagicNumber() == magic_number) { if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Violet); if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Violet); if (OrderType() > OP_SELL) OrderDelete(OrderTicket()); } } break; case 4: for (l_count_4 = 0; l_count_4 <= l_ord_total_0; l_count_4++) { OrderSelect(0, SELECT_BY_POS, MODE_TRADES); if (OrderComment() == comment_text) { if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Violet); if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Violet); if (OrderType() > OP_SELL) OrderDelete(OrderTicket()); } } break; case 5: for (l_count_4 = 0; l_count_4 <= l_ord_total_0; l_count_4++) { OrderSelect(0, SELECT_BY_POS, MODE_TRADES); if (OrderProfit() > 0.0) { if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Violet); if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Violet); if (OrderType() > OP_SELL) OrderDelete(OrderTicket()); } } break; case 6: for (l_count_4 = 0; l_count_4 <= l_ord_total_0; l_count_4++) { OrderSelect(0, SELECT_BY_POS, MODE_TRADES); if (OrderProfit() < 0.0) { if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Violet); if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Violet); if (OrderType() > OP_SELL) OrderDelete(OrderTicket()); } } break; case 7: for (l_count_4 = 0; l_count_4 <= l_ord_total_0; l_count_4++) { OrderSelect(0, SELECT_BY_POS, MODE_TRADES); if (TimeDay(OrderOpenTime()) < TimeDay(TimeCurrent())) { if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Violet); if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Violet); if (OrderType() > OP_SELL) OrderDelete(OrderTicket()); } } } return (0); } void CloseAllTrades(int ai_0, int ai_4) { for (int li_8 = OrdersTotal() - 1; li_8 >= 0; li_8--) { OrderSelect(0, SELECT_BY_POS, MODE_TRADES); if (ai_0 && OrderSymbol() != Symbol()) continue; if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Violet); if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Violet); if (ai_4 && OrderType() > OP_SELL) OrderDelete(OrderTicket()); } } void CloseAllPending(int ai_0) { for (int li_4 = OrdersTotal() - 1; li_4 >= 0; li_4--) { OrderSelect(0, SELECT_BY_POS, MODE_TRADES); if (ai_0 && OrderSymbol() != Symbol()) continue; if (OrderType() > OP_SELL) OrderDelete(OrderTicket()); } } int CountPending(bool ai_0) { int l_count_4 = 0; for (int l_pos_8 = OrdersTotal() - 1; l_pos_8 >= 0; l_pos_8--) { OrderSelect(l_pos_8, SELECT_BY_POS); if (OrderType() > OP_SELL) { if (ai_0 && OrderSymbol() == Symbol()) l_count_4++; else if (!ai_0) l_count_4++; } } return (l_count_4); } int CountOpenTrades(bool ai_0, int ai_4) { int l_cmd_16; int l_count_8 = 0; for (int l_pos_12 = OrdersTotal() - 1; l_pos_12 >= 0; l_pos_12--) { OrderSelect(l_pos_12, SELECT_BY_POS); l_cmd_16 = OrderType(); if (l_cmd_16 == OP_BUY || l_cmd_16 == OP_SELL) { if (ai_0 && OrderSymbol() == Symbol()) l_count_8++; else if (!ai_0) l_count_8++; } else { if (OrderType() > OP_SELL && ai_4) { if (ai_0 && OrderSymbol() == Symbol()) l_count_8++; else if (!ai_0) l_count_8++; } } } return (l_count_8); } Quote Link to comment Share on other sites More sharing options...
megainvest Posted September 27, 2009 Report Share Posted September 27, 2009 Re: How to close all orders in MT4 ?!?! Imprtant!! Hi How to use this script? Thanks for your explication in advance. Best regards, megainvest Quote Link to comment Share on other sites More sharing options...
Phoenix1713006089 Posted September 27, 2009 Report Share Posted September 27, 2009 Re: How to close all orders in MT4 ?!?! Imprtant!! Hi How to use this script? Thanks for your explication in advance. Best regards, megainvest drag and drop it on your chart and it will close everything Quote Link to comment Share on other sites More sharing options...
megainvest Posted September 27, 2009 Report Share Posted September 27, 2009 Re: How to close all orders in MT4 ?!?! Imprtant!! I have tried this but this unfortunately don't works. I can't attach this to the cart. Can you please post an upload of this software? Thanks, megainvest Quote Link to comment Share on other sites More sharing options...
hrdforex Posted September 27, 2009 Report Share Posted September 27, 2009 Re: How to close all orders in MT4 ?!?! Imprtant!! Use this link : http://zalil.ru/28020489 Quote Link to comment Share on other sites More sharing options...
karanmehta Posted September 27, 2009 Report Share Posted September 27, 2009 Re: How to close all orders in MT4 ?!?! Imprtant!! Find attached the script which will close all open MT4 positions. If you want to be chosy, It has setting options for which orders to close and is helpful for closing a large number of open or pending positions quickly. It also has the option to just close trades with a specific magic number. INSTRUCTIONS FOR USE 1. Download the files from "hxxp://www-dot-mediafire-dot-com/?sharekey=615a9bc3a712ebace7c82ed4b8f0c380e04e75f6e8ebb871" 2. Copy "CloseOrders.ex4" file inside folder of your broker (Something like "C:\Program Files\(Your Broker Name)\experts\scripts") and when you want to use it, simply drag it on the chart. DO DEMO TESTING BEFORE TRYING IT ON LIVE ACCOUNTS. GOODLUCK! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.