I used to press F9 to open my new order.but i couldn't find any hotkey for close order and modify order.any solution?
Hotkey script MT4 open-close orders 17 replies
MT4 Order Pending Order/Order Modify Issue 1 reply
MT4 and Line Study Hotkey 4 replies
can i create a hotkey that executes keystrokes? 1 reply
Can anyone share Buy-Sell-Close scripts to use as a hotkey without using F9 option? 5 replies
//+------------------------------------------------------------------+ //| close.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property show_confirm //+------------------------------------------------------------------+ //| script "close first market order if it is first in the list" | //+------------------------------------------------------------------+ int start() { int total = OrdersTotal(); for(int i=total-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); bool result = false; switch(type) { //Close opened long positions case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); break; //Close opened short positions case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); } if(result == false) { // Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() ); if(!IsTesting( ) ) Sleep(3000); } } return(0); }
Dislikedoh, i found it, You have to goto setings and allow live trades by expert advisors.
i'm using my own close code now
Inserted Code//+------------------------------------------------------------------+ //| close.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property show_confirm //+------------------------------------------------------------------+ //| script "close first market order if it is first in the list" | //+------------------------------------------------------------------+ int start() { int total = OrdersTotal(); for(int i=total-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); bool result = false; switch(type) { //Close opened long positions case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); break; //Close opened short positions case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); } if(result == false) { // Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() ); if(!IsTesting( ) ) Sleep(3000); } } return(0); }Ignored