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. |
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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);
}
}