Checking if the last trade was profitable or not

 

I can check the open price

I can not get the close price to compare them.

HistoryOrderGetDouble(HistoryOrderGetTicket(HistoryOrdersTotal()-1),ORDER_PRICE_OPEN);
 
wehsnim:

I can check the open price

I can not get the close price to compare them.

Did you select your history ?
 
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(typeor==ORDER_TYPE_BUY)
     {
      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.

Oh.. Let Me Switch to History Deal  I read your post and thought your where talking about

  HistorySelect(0,TimeCurrent());  // request trade history
 
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.

Oh.. Let Me Switch to History Deal  I read your post and thought your where talking about

Yes I am talking about HistorySelect(). You always have to select your history before using HistoryXXX functions.
 
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);
                  }
               }
 
Suggestion to everyone looking for this type of information read Orders Positions and Deals
Reason: