Hi
I have this code and i select order #12345, OrderSelect function always return true even when order closed with takeprofit
Why?
Because it is a bool value which returns only true or faluse
see below
bool OrderSelect( int index, // index or order ticket int select, // flag int pool=MODE_TRADES // mode );
- docs.mql4.com
OrderSelect - Trade Functions - MQL4 Reference
Because it is a bool value which returns only true or faluse
see below
It shouldn't return false when i select order that closed ?!
If not how can i know order closed with tp or sl ???
It shouldn't return false when i select order that closed ?!
If not how can i know order closed with tp or sl ???
It shouldn't return false when i select order that closed ?!
If not how can i know order closed with tp or sl ???
- OrderSelect() returns true if the function succeeds (if it could select the order), otherwise false (in your case if the ticket doesn't exist). It has nothing to do with opened/closed order
- If you want to know if the order was closed by TP or SL you have to find out if the order is closed first by OrderCloseTime() and then you can compare OrderClosePrice() with your SL and TP.
If not how can i know order closed with tp or sl ???
- It doesn't.
- If you select by position in the trade pool you get open and pending orders.
- If you select by position in the history pool you get closed, deleted and adjustments.
- If you select by ticket you get the ticket. PERIOD. It may be pending, open, closed, or deleted - you must check.
- You only get false if you use a non-existent position or ticket.
- In MT5 you can find out. There isn't anything in MT4. Best you can do is see if the OrderClosePrice is nearer to TP or SL.
When you specify the ticket number the pool parameter is complete ignored, so when you use the ticket number and the order is closed you are selecting it from the MODE_HISTORY pool. It's returning true because the order functions are correctly pointed to it now.
Ty Emma, it's my answer. i understand my mistake about pool parameter...
ty everybody that help me
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I have this code and i select order #12345, OrderSelect function always return true even when order closed with takeprofit
Why?