where was last trade made ; from bid or from ask ? - page 2

 
prevBid=Bid, prevAsk=Ask ... Next tick ... If Last()==prevBid then Bid else Ask.
Something like this.
 

Sorry as I said I am novice.

I read about struct MqlTick. There we can find all the information about last trade.

But something is not clear for me; how to code to find: "WAS LAST TRADE A BUY OR A SELL" 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Structure for Current Prices
Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Structure for Current Prices
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / Structure for Current Prices - Documentation on MQL5
 
I am not at my computer at the moment. Compare previous MqlTick and current MqlTick then you will know the different. I will test it on Monday when the market is open. I am curious too.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Structure for Current Prices
Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Structure for Current Prices
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / Structure for Current Prices - Documentation on MQL5
 

Well, hope to find a solution !

 
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 ?".

You have to check the deals and find the last one : see here for an example of processing the deals.
 
angevoyageur:
You have to check the deals and find the last one : see here for an example of processing the deals.
Thank you for your suggestion.I read the example. But how can I find the last deal ?
 
tenlau:
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?"
So you want someone to code this for you ?  go here:  Jobs
 
tenlau:
Thank you for your suggestion.I read the example. But how can I find the last deal ?
Compare the dates (DEAL_TIME) and keep the greater.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties - Documentation on MQL5
 
angevoyageur:
Compare the dates (DEAL_TIME) and keep the greater.

Thank you again! But don't you think is easier to use the MqlTick structure and code something like:

 MqlTick latest_price; 
   if(latest_price.ask==latest_price.last)
    Comment(StringFormat("It is a BUY"));
   if(latest_price.bid==latest_price.last)
    Comment(StringFormat("It is a SELL"));
   
 
tenlau:

Thank you again! But don't you think is easier to use the MqlTick structure and code something like:

If the last trade was made during the last tick . . . then yes.  When was the last trade made ?

Perhaps there are some crossed wires in this thread . . . .     Are you talking about all trades or just the trades you have placed ?