# Checking if the last trade was profitable or not

What is a social trading? Read the article to find that out!
350
2014.05.29 06:27

I can check the open price

I can not get the close price to compare them.

```HistoryOrderGetDouble(HistoryOrderGetTicket(HistoryOrdersTotal()-1),ORDER_PRICE_OPEN);
```
Moderator
30752
2014.05.29 10:49
wehsnim:

I can check the open price

I can not get the close price to compare them.

Did you select your history ?
350
2014.05.29 11:32
angevoyageur:
Did you select your history ?

Im breaking down the Martingale Library to understand how it works yet its not based on if a trade is loss double up. from my understanding so far

```   double cl=HistoryOrderGetDouble(HistoryOrderGetTicket(HistoryOrdersTotal()-1),ORDER_PRICE_OPEN); //Double Because of ORDER_PRICE_OPEN
double op=HistoryOrderGetDouble(HistoryOrderGetTicket(HistoryOrdersTotal()-2),ORDER_PRICE_OPEN); //Double Because of ORDER_PRICE_OPEN

//Get the Properties in (Ticket History (list of order history () second from the last ),
long typeor=HistoryOrderGetInteger(HistoryOrderGetTicket(HistoryOrdersTotal()-2),ORDER_TYPE); // HistoryOrderGetInterger Because of OrderType
{
if(op>cl)
{
if(ud<DoublingCount)
{
lt1=HistoryOrderGetDouble(HistoryOrderGetTicket(HistoryOrdersTotal()-2),ORDER_VOLUME_INITIAL)*2; //Double Because of Order Volume Initial
ud++;
}
else ud=0;
}
else ud=0;
}```

just if the 2nd to last order open price is greater than the last order open price.

`  HistorySelect(0,TimeCurrent());  // request trade history`
Moderator
30752
2014.05.29 13:09
wehsnim:

Im breaking down the Martingale Library to understand how it works yet its not based on if a trade is loss double up. from my understanding so far

just if the 2nd to last order open price is greater than the last order open price.

Yes I am talking about HistorySelect(). You always have to select your history before using HistoryXXX functions.
350
2014.05.30 09:53
angevoyageur:
Yes I am talking about HistorySelect(). You always have to select your history before using HistoryXXX functions.

It wont print the profit, thus no comparison is possible

```void ScanClosedTrades()
{
HistorySelect(0,TimeCurrent());

ulong  ticket = 0;
double profit;
uint   dealsTotal=HistoryDealsTotal();
//--- Loop for tracking wins losses and lot sizes for trading

for (uint i=0; i < dealsTotal; i++)
{
if((ticket=HistoryDealGetTicket(i))>0)
{
profit=HistoryDealGetDouble(ticket,DEAL_PROFIT);

}

if (profit < 0)
{
Print("Profit: %f",CheckProfit);//profit);
}
}
```
350
2014.05.31 10:26
Suggestion to everyone looking for this type of information read Orders Positions and Deals