I am implementing the EA with mql5. I would like to know how can I retrieve the most recent open position. As I am using buy limit and buy stop, it
can't use the highest ticket number to refer to the latest open position. What function should I use? Could anyone please give any
suggestion?
- How to get the maximum number of open positions
- Retrieving Last closed Order's Ticket
- converting string to uLong
Tanitsak Jirawuttanakit:
I am implementing the EA with mql5. I would like to know how can I retrieve the most recent open position. As I am using buy limit and buy stop, it can't use the highest ticket number to refer to the latest open position. What function should I use? Could anyone please give any suggestion?
I am implementing the EA with mql5. I would like to know how can I retrieve the most recent open position. As I am using buy limit and buy stop, it can't use the highest ticket number to refer to the latest open position. What function should I use? Could anyone please give any suggestion?
You can make use of PositionsTotal() and OrdersTotal() - check out https://www.mql5.com/en/docs/trading. (Or, if you're more adventurous, can also check out https://www.mql5.com/en/docs/standardlibrary/tradeclasses).
Time comparison will be necessary, rather than ticket number.
Documentation on MQL5: Trade Functions
- www.mql5.com
An order is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels.A deal is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is...
Tanitsak Jirawuttanakit:
I am implementing the EA with mql5. I would like to know how can I retrieve the most recent open position. As I am using buy limit and buy stop, it can't use the highest ticket number to refer to the latest open position. What function should I use? Could anyone please give any suggestion?
I am implementing the EA with mql5. I would like to know how can I retrieve the most recent open position. As I am using buy limit and buy stop, it can't use the highest ticket number to refer to the latest open position. What function should I use? Could anyone please give any suggestion?
Documentation on MQL5: Event Handling / OnTrade
- www.mql5.com
//| OnTrade_Sample.mq5 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://www.mql5.com | //| Expert initialization function |...
Thanks to every of you. I really appreciate every suggestion. I got the answer already. I think I will use time compare of each position or OnTrade(). Thanks you guys a lot :)
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