index= OrderType();
You can not use any Trade Functions until you select an order.Trade=(OrderSelect(TicketNumber,SELECT_BY_TICKET)==true);
- T = bool == true equals T = bool;
- Check your return codes for errors, report them
and you would know why.
Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after. - You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.
bool Order_Closing = OrderClose(TicketNumber,lot,Closing[index],Slippage,clrNONE);
- Check your return codes.
- You've selected the ticket, you don't need other variables, just use OrderClose(OrderTicket(), OrderLots(), OrderClosePrice().
- You are selecting by ticket, (not a OrderSelect loop through open orders.) Where do you check if the order has already closed?
- GrumpyDuckMan: some ideas pleaseYou haven't stated a problem.
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 everyone,
I am trying to simplify closing order.
some ideas please