Get last closed order proffit?

 

Hi,

I been struggling for some evenings now trying to get the proffit/loss from the last closed order and have tried alot of different codes.

When a run my Strategy Tester it feels like it misses orders? 
and i read somewhere that you can use it in Tick() or in Trade() function??

Should not this be an easy thing in a trading plaform?

Anyone that can point in right direction or have tips on how to get proffit / Loss on last closed order and so I get it everytime an order is closed?


Thanks in advance.

Stefan-Sweden

 
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
 
 

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.
 
skrantz71:

Hi,

I been struggling for some evenings now trying to get the proffit/loss from the last closed order and have tried alot of different codes.

When a run my Strategy Tester it feels like it misses orders? 
and i read somewhere that you can use it in Tick() or in Trade() function??

Should not this be an easy thing in a trading plaform?

Anyone that can point in right direction or have tips on how to get proffit / Loss on last closed order and so I get it everytime an order is closed?


Thanks in advance.

Stefan-Sweden

You can loop through all closed deals and get the profit of the last closed deals

I've been using it for my code 

Reason: