calling last closed operation

 

Hi,

I'm trying to make my first ea and I wanted to add to it that it would open a long opsition when a short one is closed and viceversa

only thing is I can't seem to find a function that calls to the last closed position,

I thought it would be one of the History, Position, or Order functions but I can't find a way.

any help would be really appreciated,

thanks.

 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

I suggest you read this Article, before anything else ...

Articles

Orders, Positions and Deals in MetaTrader 5

MetaQuotes, 2011.02.01 16:13

Creating a robust trading robot cannot be done without an understanding of the mechanisms of the MetaTrader 5 trading system. The client terminal receives the information about the positions, orders, and deals from the trading server. To handle this data properly using the MQL5, it's necessary to have a good understanding of the interaction between the MQL5-program and the client terminal.
Reason: