how can I know the position be closed and get the profit of this postion?

 

There are more concept in MT4, postions, order,deal .how can I know the position be closed and get the profit of this postion?

Is there any sample code to learn and share?

 

thanks 

 
codeidea:

There are more concept in MT4, postions, order,deal .how can I know the position be closed and get the profit of this postion?

Function PositionSelect returns false when position wasn't found (was closed). If position was closed you should search in history deals for deal, which closed your position. Using of magic numbers should help you.