# Find out if a trade was stopped out

4527

What is a simple method to figure out that the last trade done was a loss?
130

ingvar_e:
What is a simple method to figure out that the last trade done was a loss?

Look at the history, it shows you if the trade was a loss or profit.

it also tells you in the comments for that trade, if it was because of a stop-loss or take-profit (sl: xxx or tp: xxx)

4527

johhny6:

Look at the history, it shows you if the trade was a loss or profit.

it also tells you in the comments for that trade, if it was because of a stop-loss or take-profit (sl: xxx or tp: xxx)

I tried that. I checked history after the trade had finished, the code was in progress to start a new trade. I had saved the ticket for the

I work with TP and SL so I just keep tab that these leels are reached. Not perfect but will work for now (developing and running strategy tester). If someone has a  piece of code I will try it

Code below always show zero profit even though the trade has finished

{
if (!HistorySelect(0,TimeCurrent()))
return 0;

mydeal.Ticket(ticket);
ulong morder = mydeal.Ticket();
if(morder)
{
string msymbol = mydeal.Symbol();
double mprofit = mydeal.Profit();
double mprice = mydeal.Price();
string mid = mydeal.Comment();
if(mprofit>0)
{
return 1;
}
if(mprofit<0)
{
return -1;
}

}
else
return 0;
}

5241

ingvar_e:

Hi

What does this mean?

mydeal.Ticket(ticket);
ulong morder = mydeal.Ticket();
if(morder)
{
//---

I think you should select the most recent order by its position's index and I think this is equal to the total history orders minus one.

4527

ssn:

Hi

What does this mean?

I think you should select the most recent order by its position's index and I think this is equal to the total history orders minus one.

I just save the  ticket for the previous trade in "Ticket" and use that to retrieve the data for it. It works. Other data that I receive this way

are for the previous trade so its correct. It is just that  mydeal.Profit()  is always zero and that is incorrect. I have both SL and TP profit set