Hi everyone! Trying to get the "paid" or "incurred" spread for an Order.

 

It is pretty easy to get the current spread on a pair, and it looks something like this in my code.

string infotext2222  = " Current Spread: "+DoubleToStr((Ask - Bid)/pips,1);

However, I also want to display the spread that I "paid" or that existed on my last trade. So say I took a trade at 11:00 and the spread was 5, I would want it to display this number afterwards.

So far I thought of using "OpenOrderPrice" but that would only give you the Ask or Bid depending on whether you took a Buy or Sell and not the counterpart. 

I also tried pin-pointing the time at which the trade takes place but without success ... It looks like this for example:

string paidspreadlong = "0";  
 
if((OpenOrdersThisPair(Symbol())>=1))

   {      

      for(int B=OrdersTotal()-1;B>=0;B--)

      {

         if(OrderSelect(B,SELECT_BY_POS,MODE_TRADES))

           if(OrderOpenTime()==TimeCurrent())

               if(OrderType()==OP_BUY)

                  {                                           

                  paidspreadlong = DoubleToStr((Ask-Bid)/pips,1);

                  }

      }

So my question is: is it possible? I feel like it shouldn't be too complicated yet its been something troubling me for quite some time now.
 

I have never needed to do this and there may be innacuracies due to possible new ticks.

You could check the spread just before you open the trade.

You could open the trade then immediately select it and calculate the difference between OrderOpenPrice() and OrderClosePrice()

 
Rednamalas: I also want to display the spread that I "paid" or that existed on my last trade.
For a buy order you pay when you open the order. For a sell, when you close it.