Please don't post randomly in any section. Your question is not related to the section you posted.
MT4/mql4 has it's own section on the forum.
I will move your topic to the correct section later, please don't create an other topic.
- Usually people who cannot code do not receive free help on this forum, although it could happen if you are lucky. Be patient.
- If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community.
- If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free).
- Finally, you also have the option to hire a programmer in the Freelance section.
Vishal Agarwal:
Hello guys please help me
i want a expert advisor for MT4 which is delete all pending orders if there is no open order.
if any open order no pending order is closed.
//+------------------------------------------------------------------+ //| close-all-orders.mq4 | //| Copyright © 2005, Matias Romeo. | //| Custom Metatrader Systems. | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, Matias Romeo." #property link "mailto:matiasDOTromeoATgmail.com" bool result = 0; int start() { result = 0; OrderStatus(); if(result==0) { 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 //Close pending orders case OP_BUYLIMIT : case OP_BUYSTOP : case OP_SELLLIMIT : case OP_SELLSTOP : result = OrderDelete( OrderTicket() ); } if(result == false) { if (GetLastError()>0) Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() ); Sleep(3000); } } } return(0); } int OrderStatus() { int total = OrdersTotal(); for(int i=total-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); switch(type) { case OP_BUY: case OP_SELL: result = result+1; } } return(0); }
Vishal Agarwal:
Hello guys please help me
i want a expert advisor for MT4 which is delete all pending orders if there is no open order.
if any open order no pending order is closed.
//+----------------------------------------------------------------------------+ //| Close_All_Orders.mq4 | //| Francisco Rayol | //| https://twitter.com/mql4all | //+----------------------------------------------------------------------------+ #property copyright "EA's and Indicators for Funds and Prop Desks (Risk Management EAs)." #property link "https://www.mql5.com/en/users/rayolf/seller" //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- CloseAllPendingOrders(); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool CheckOpenMarketOrders() { for(int i = 0 ; i < OrdersTotal() ; i++) { bool res = OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=1)return(true); } return(false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CloseAllPendingOrders() { for(int i=OrdersTotal()-1; i >= 0; i--) { bool res=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderType()>1 && CheckOpenMarketOrders()==false) { bool result=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5,NULL); } } }
Files:
Close_forum.mq4
3 kb
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello guys please help me
i want a expert advisor for MT4 which is delete all pending orders if there is no open order.
if any open order no pending order is closed.