I have some trouble understanding the methods OnMarketData and OnBarUpdate.
I want to get the current ask/bid price (and not a historical value) every time a new tick comes in and save it to a variable. When the second tick comes in, I can compare the value from tick 2 with tick 1. I'm using "OnMarketData(..)" for that, but somehow it gets called more frequently than a new tick comes in.
I have created a simple script just to log the incoming ticks:
protected override void OnMarketData(MarketDataEventArgs e)
{
if (e.MarketDataType == MarketDataType.Ask)
{
Print (GetCurrentAsk());
}
}
This method is called sometimes 5 times a second, although just one tick came in per second. Why?
Also, I don't use OnBarUpdate(), because whenever I start the script, it returns all previous ticks. I don't want any historical data when I start my script.
Any advice?
Thank you!
Robert
Comment