the first example just looks at position 0 with 10millisecond gaps and store in queue.
so position 0 is the bestbid bestoffer, correct?
This work fines, the changes are printed to the print statement and appear to change about the same frequency.
but the next script, only the bid seems to update in about the the same frequency as the bid on the first script, the ask is very slow on the second script. I cannot see any reason why, they are coded the same just else statements on the second script.
the bid is timely but the ask is lagging.
I also note that the postions go upto 9 on the emini ES contract on the ask side, and when i look at those numbers, they dont look as "orderly" as the bid side
Tinkerz
protected override void OnMarketDepth(MarketDepthEventArgs e)
{
if (startbar==-1) startbar=CurrentBar;
lastcalcbar=CurrentBar;
if (ShowBidorAsk==true)
{
if (e.MarketDataType == MarketDataType.Ask && e.Position==0 && AskTimecounter<DateTime.Now.TimeOfDay.TotalMilliseconds)
{
AskTimecounter= (DateTime.Now.AddMilliseconds(10).TimeOfDay.TotalMilliseconds);
AskStack.Enqueue((double)e.Volume);
int countC=AskStack.Count;
if (countC>stacklength)
{
AskStack.Dequeue();
}
Print("Asks0//"+AskStack.Count);
}
}
else
{
if (e.MarketDataType == MarketDataType.Bid && e.Position == 0 && BidTimecounter<DateTime.Now.TimeOfDay.TotalMilliseconds)
{
BidTimecounter= (DateTime.Now.AddMilliseconds(10).TimeOfDay.TotalMilliseconds);
BidStack.Enqueue((double)e.Volume);
int countD=BidStack.Count;
if (countD>stacklength)
{
BidStack.Dequeue();
}
Print("Bidss0//"+BidStack.Count);
}
}
}
basically the same as the first, just splitting out the positions into queues
protected override void OnMarketDepth(MarketDepthEventArgs e)
{
if (startbar==-1) startbar=CurrentBar;
lastcalcbar=CurrentBar;
if (ShowBidorAsk==true)
{
if (e.MarketDataType == MarketDataType.Ask && AskTimecounter<DateTime.Now.TimeOfDay.TotalMilliseconds)
{
AskTimecounter= (DateTime.Now.AddMilliseconds(10).TimeOfDay.TotalMilliseconds);
// Print("Asks0postion//"+e.Position);
if (e.Position==0)
{
AskLimit0=e.Volume;
AskStack0.Enqueue((double)e.Volume);
countC0=AskStack0.Count;
if (countC0>stacklength)
{
AskStack0.Dequeue();
}
Print("Asks0//"+AskStack0.Count);
}
else
if (e.Position==1)
{
AskLimit1=e.Volume;
AskStack1.Enqueue((double)e.Volume);
countC1=AskStack1.Count;
if (countC1>stacklength)
{
AskStack1.Dequeue();
}
// Print("Asks1//"+AskStack1.Count);
}
else
if (e.Position==2)
{
AskLimit2=e.Volume;
AskStack2.Enqueue((double)e.Volume);
countC2=AskStack2.Count;
if (countC2>stacklength)
{
AskStack2.Dequeue();
}
// Print("Asks2//"+AskStack2.Count);
}
else
if (e.Position==3)
{
AskLimit3=e.Volume;
AskStack3.Enqueue((double)e.Volume);
countC3=AskStack3.Count;
if (countC3>stacklength)
{
AskStack3.Dequeue();
}
// Print("Asks3//"+AskStack3.Count);
}
else
if (e.Position==4)
{
AskLimit4=e.Volume;
AskStack4.Enqueue((double)e.Volume);
countC4=AskStack4.Count;
if (countC4>stacklength)
{
AskStack4.Dequeue();
}
// Print("Asks4//"+AskStack4.Count);
}
}
}
else
if (e.MarketDataType == MarketDataType.Bid && BidTimecounter<DateTime.Now.TimeOfDay.TotalMilliseconds)
{
BidTimecounter= (DateTime.Now.AddMilliseconds(10).TimeOfDay.TotalMilliseconds);//
// Print("Bids0postion//"+e.Position);
if ( e.Position == 0)
{
BidLimit0=e.Volume;
BidStack0.Enqueue((double)e.Volume);
countD0=BidStack0.Count;
if (countD0>stacklength)
{
BidStack0.Dequeue();
}
Print("Bids//"+BidStack0.Count);
}
else
if ( e.Position == 1)
{
BidLimit1=e.Volume;
BidStack1.Enqueue((double)e.Volume);
countD1=BidStack1.Count;
if (countD1>stacklength)
{
BidStack1.Dequeue();
}
}
else
if ( e.Position == 2)
{
BidLimit2=e.Volume;
BidStack2.Enqueue((double)e.Volume);
countD2=BidStack2.Count;
if (countD2>stacklength)
{
BidStack2.Dequeue();
}
}
else
if ( e.Position == 3)
{
BidLimit3=e.Volume;
BidStack3.Enqueue((double)e.Volume);
countD3=BidStack3.Count;
if (countD3>stacklength)
{
BidStack3.Dequeue();
}
}
else
if ( e.Position == 4)
{
BidLimit4=e.Volume;
BidStack4.Enqueue((double)e.Volume);
countD4=BidStack4.Count;
if (countD4>stacklength)
{
BidStack4.Dequeue();
}
}
}
// try{ChartControl.Refresh();}
// try{}
// catch {}
}

Comment