If I receive data in the main() function and call getMostRecentBid() and also getMostRecentTrade() and the current trade that triggered the call to the main() function was on the bid side then will the two be the same?
i.e. My question is really: Does getMostRecentBid() (etc.) relate to the trade and details of the trade that are currently being processed in the main() function or is it possible that getMostRecentBid() checks the buffer of trades lined up to be processed by main() and as such this processing logic of mine will fall apart? (Obviously the reason that I am asking this is because this logic currently doesn't work.)
What I am trying to achieve through the logic above is to work out if the current trade that I am processing in the main() function went through on the bid or ask side. If anybody has another suggestion how I can achieve that then that would make me happier than Larry as well.
wildfiction
As far as I know on first load (or subsequent reloads) of an efs getMostRecentBid/Ask will return the most current Bid/Ask. In real time getMostRecentBid/Ask will return the last Bid/Ask quoted prior to the trade that triggered the execution of main
Alex
So the getMostRecentBid/Ask() accesses values that are passed into the main() with the price data and doesn't call out to the buffer of prices that are queue for the main() function?
Thanks Alexis - I think that explains the problem that I am experiencing - in fast moving markets the getMostRecentBid/Ask() appears to be ahead of what you see in the main() function and so cannot be used accurately in the main() function unless the market is moving slowly.
It surprises me that there is no way to tell which side of the market the current trade in main() traded on. I would have thought that functionality would be a basic requirement for a charting package...
wildfiction
getMostRecentBid/Ask() cannot be ahead because they are the last Bid/Ask prints prior to the trade that executed main().
What you may be seeing could be due to how an efs executes in minute based charts with some electronically traded contracts (such as for example ES and NQ). In these cases an efs will execute only when
- Current trade price is different than the previous trade price.
- Current trade price is at the bid and previous trade was at the ask or vice versa. The two trade prices can be the same in this instance.
With tick based charts (Tick, Volume, Seconds or Price-change) instead an efs executes on every trade
As to being able to tell which side a trade was on you should be able to do that by evaluating if getMostRecentTrade() is equal to getMostRecentAsk() or to getMostRecentBid()
As an example see the the two images enclosed below. The first one was taken using a minute based chart of YM M6 and shows a trade at the Bid and one at the Ask. The second image instead was taken using a tick based chart and shows that the efs is executed on every trade even if this is at the same price and side of the prior one.
In all cases getMostRecentBid/Ask() returned the last Bid and Ask prior to the trade.
Alex
Comment