Please, help!
I’m developing a script and I need data of historical ticks. I need the tick’s time, price, volume and whether it was filled at ask or at bid.
For real-time trades I used the following code inside OnMarketData() method
protected override void OnMarketData(MarketDataEventArgs e)
{
if (e.MarketDataType == MarketDataType.Last)
{
string side = null;
if(e.Price > GetCurrentBid())
{
side = "ask";
}
if(e.Price < GetCurrentAsk())
{
side = "bid";
}
}
}
I have read the help guide and found the following solution for historical ticks.
protected override void Initialize()
{
Add("CL", PeriodType.Tick, 1, MarketDataType.Ask);
Add("CL", PeriodType.Tick, 1, MarketDataType.Bid);
}
Then I tried to check the tick data by the following code inside OnStartUp() method
protected override void OnStartUp()
{
for(int i = 0; i < 10; i++)
{
Print(Close[1][i]);
Print(Close[2][i]);
}
}
The same code I tried inside OnBarUpdate() method.
Each time I’ve got two zeros in Output window, not even 10 times of two zeros as a size of the loop.
My question is what is wrong with my code? How can I get whether the historical tick happened at ask or bid side?
I will really appreciate any code example to solve my problem.
Regards.
Comment