[MQL4 CODE] How to calculate the transaction price of the last short order?

/**
 * How to calculate the transaction price of the last short order?
 */
double MagicNumber=1111;
double Find_Last_Sell_Price() 
{
   double oldorderopenprice=0, orderprice; 
   int cnt, oldticketnumber=0, ticketnumber; 
   for(cnt=OrdersTotal()-1;cnt>=0;cnt--) 
   { 
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); 
      if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber) 
      continue; 
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderType()==OP_SELL) 
      { 
         ticketnumber=OrderTicket(); 
         if(ticketnumber>oldticketnumber) 
         { 
            orderprice=OrderOpenPrice(); 
            oldorderopenprice=orderprice; 
            oldticketnumber=ticketnumber; 
         } 
      } 
   } 
   return(orderprice);
}
#property copyright "Copyright 2021, www.comefx.com"
#property link      "https://www.comefx.com"
#property version   "1.00"
#property strict

Leave a comment

All comments are moderated before being published

Best Sellers

ADVANCED ARTIFICIAL INTELLIGENCE FOREX TRADING ROBOT FOR YOU

Comefx