Your topic has been moved to the section: MQL4 e MetaTrader 4 — In the future, please consider which section is most appropriate for your query.
- Usually people who cannot code do not receive free help on this forum.
- If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
- 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.
sm neverland: How can i close the last order opened by order type . when there are multiple orders opened. Any help will be much appreciated.
-
OrderSelect loop, find the latest open time of your type; remember the ticket number. Select the ticket and close it. What's the problem?
-
Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
No free help (2017)Or pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum (2018)We're not going to code it for you (although it could happen if you are lucky or the issue is interesting).
No free help (2017)
// last orderinfo double LastOrderInfo(string Info,int type=-1 ) { for(int i =OrdersTotal() -1 ; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderType()== type || type ==-1) ) { if(Info=="Type") return (OrderType()); else if(Info=="SL") return (OrderStopLoss()); else if(Info=="TP") return (OrderTakeProfit()); else if(Info=="Lots") return (OrderLots()); else if(Info=="Price") return (OrderOpenPrice()); else if(Info=="Profit") return (OrderProfit()); else if(Info=="Time") return (OrderOpenTime()); } } return (0); }
u can creet the (the last order info ) like that
void CloseLastBuy() { for(int i=OrdersTotal()-1;i>=0;i--) { if(!OrderSelect(i, SELECT_BY_POS)) continue; if(OrderType()!=OP_BUY) continue; OrderClose(...); return; } }
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
Hi
I am a novice in MQL4
How can i close the last order opened by order type . when there are multiple orders opened.
I mean i want close buy position just close last buy opened position and for sell too.
or i want any expert like this if you have.
Sorry for my weak language.
Please,
Any help will be much appreciated.
Thanks.