where was last trade made ; from bid or from ask ?

 

Hello,

It is a very novice question, but for me is very hard. I want to find from where was last trade made; from BID price or from ASK price.

Thank you in advance for your reply ! 

 
tenlau:

Hello,

It is a very novice question, but for me is very hard. I want to find from where was last trade made; from BID price or from ASK price.

Thank you in advance for your reply ! 

If it was a Buy it was from Ask,  if it was a Sell it was from Bid,  vis versa when closing the trades . . . . .  a Sell is closed with a Buy at Ask.
 
RaptorUK:
If it was a Buy it was from Ask,  if it was a Sell it was from Bid,  vis versa when closing the trades . . . . .  a Sell is closed with a Buy at Ask.
Sorry maybe my question was not so clear. I want to check in mql5 language if last trade was made from bid (or ask). How can I do it? In other words find if last trade was done at bid price or ask price. Hope now is clear!
 
tenlau:
Sorry maybe my question was not so clear. I want to check in mql5 language if last trade was made from bid (or ask). How can I do it? In other words find if last trade was done at bid price or ask price. Hope now is clear!
You mean if it is a sell or a buy ?
 
tenlau:
Sorry maybe my question was not so clear. I want to check in mql5 language if last trade was made from bid (or ask). How can I do it? In other words find if last trade was done at bid price or ask price. Hope now is clear!
Select it and check it's ORDER_TYPE using OrderGetInteger()
 
angevoyageur:
You mean if it is a sell or a buy ?
Yes, I want to know if last trade was sell or buy. How to code it in mql5 ?
 
RaptorUK:
Select it and check it's ORDER_TYPE using OrderGetInteger()
Sorry again. My question is about how to code in mql5 language the following question: "Last trade in market was a buy or a sell?"
 

And one more specification: Is not about a trade in the past. 

I want to use the code in an expert advisor, so I want to know in real time : "was the last trade a buy or a sell ?".

 
tenlau:
Sorry maybe my question was not so clear. I want to check in mql5 language if last trade was made from bid (or ask). How can I do it? In other words find if last trade was done at bid price or ask price. Hope now is clear!
Person A sold x to Person B. Person B bought x from Person A. This is last traded price where Ask and Bid are equal (meet). The last price will move back and forth between the bid and ask prices.
 
tenlau:

And one more specification: Is not about a trade in the past. 

I want to use the code in an expert advisor, so I want to know in real time : "was the last trade a buy or a sell ?".

double  Last() - See https://www.mql5.com/en/docs/standardlibrary/tradeclasses/csymbolinfo/csymbolinfolast
Documentation on MQL5: Standard Library / Trade Classes / CSymbolInfo / Last
Documentation on MQL5: Standard Library / Trade Classes / CSymbolInfo / Last
  • www.mql5.com
Standard Library / Trade Classes / CSymbolInfo / Last - Documentation on MQL5
 
double last() return the last price as a value, but did not tell nothing about it was a sell or a buy....
Reason: