Download MetaTrader 5

Find price difference between last closed order and current close price ??? How To?

To add comments, please log in or register
Deposit to your account via Visa QIWI Wallet
Sherif Hasan
7290
Sherif Hasan 2015.08.01 11:29 
double ClosedPrice = 0;
double ClosePrice=Close[0];
//double GapinPips=0;
datetime lastCloseTime = 0;
int cnt = OrdersHistoryTotal();
for (int i=0; i < cnt; i++)
{
    if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
    if (OrderSymbol() == Symbol() && lastCloseTime < OrderCloseTime())
    {
        lastCloseTime = OrderCloseTime();
        ClosedPrice = OrderClosePrice();
    }
}

double GapinPips=ClosePrice-ClosedPrice;
Comment(GapinPips);

Why its not giving the difference value between last closed order and current close price?

please mention my logic error!

whroeder1
14532
whroeder1 2015.08.01 18:29  
  1. It is
  2. Close[0] == Bid
  3. price - price is not pips.
To add comments, please log in or register