How to get reslut of trade just closed (profit/loss)
You have to select the order by its ticket from history orders.
Then you get the profit (in $) by OrderProfit()
Then you get the profit (in $) by OrderProfit()
mtbb805: TpAmount+=OrderTicket(OrderProfit);
- When you post code please use the SRC button! Please edit your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum - OrderTicket(whatever) is bogus. Perhaps you should read the manual.
OrderProfit - Trade Functions - MQL4 Reference - Select an order by ticket first. Remember net profit = OrderProfit() + OrderSwap() + OrderCommission()
I have a scirpt that will close all trades.. At the end it prints that the trade was closed successfully... Can i add this line of code (TpAmount+=OrderTicket(OrderProfit);) and get the profit/loss of the trade just closed and have it add to my previous TpAmount variable?
here is the code...
{ Print("* ",OrderSymbol(),", ticket: ",OrderTicket()," closed.");
TpAmount+=OrderTicket(OrderProfit);
break;
}