Last Trade!

 

Hey Guys, i've built an EA and i want to select the very last closed trade. I've tried everything that is in my skillbox. I've researched the forum and read every function that would help me in the documentary, i can't solve this.

I need the ticket of the very last closed Trade, so the EA can differ between loss/win trade (not a problem if get the ticket) and adjust the lot-size for the next trade.

Thank you! :)

 
lawbreaker13:

Hey Guys, i've built an EA and i want to select the very last closed trade. I've tried everything that is in my skillbox. I've researched the forum and read every function that would help me in the documentary, i can't solve this.

I need the ticket of the very last closed Trade, so the EA can differ between loss/win trade (not a problem if get the ticket) and adjust the lot-size for the next trade.

Thank you! :)

Learn to use the search and then you won't have to wait for someone to reply to your post . . .

https://www.mql5.com/en/forum/145866

 

You can do it in lot of ways.

1. You can compare the tickets and get the higher one

2. You can store in a variable the last lot size

 
maleas_k:

You can do it in lot of ways.

1. You can compare the tickets and get the higher one

2. You can store in a variable the last lot size


the last closed trade has not always the highest ticketnumber ....

check OrderCloseTime

 
lawbreaker13: i've built an EA and i want to select the very last closed trade. I've tried everything that is in my skillbox.
Show us your code. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
 

Try this:

OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY)
Reason: