Login Page - Create Account

Support Board


Date/Time: Sun, 16 Mar 2025 16:43:17 +0000



[Programming Help] - MBO tick data issue

View Count: 583

[2022-08-16 04:17:42]
User785723 - Posts: 58
I’m using ACSIL to get and store MBO tick data on the ask and bid side.

I am considering sc.LastTradePrice and expecting that the minimum ask order is always above and the maximum bid order is always below sc.LastTradePrice.

However, for around 20% of the stored data, this is not the case i.e., either:
minimum ask order price < sc. LastTradePrice
or
maximum bid order price > sc.LastTradePrice

How can I address this issue?

Also I wonder if the trader id for each of the orders can be obtained via ACSIL for MBO data.
[2022-08-16 05:36:19]
User907968 - Posts: 838
Take a look at the example, scsf_MarketLimitOrdersForPriceExample, found in studies2.cpp.
If you follow the example then you are guaranteed to start at the correct best bid / offer prices.
[2022-08-16 06:27:42]
User785723 - Posts: 58
Great! Thanks

Can you elaborate what is the reason behind this line?

int ActualLevels = sc.GetAskMarketLimitOrdersForPrice(sc.Round(MarketDepthEntry.Price / sc.TickSize), NumberOfMarketOrderDataElements, MarketOrderData);
[2022-08-16 06:42:47]
User907968 - Posts: 838
Yes, sure.
It gives you the actual number of used elements in the MarketOrderData array, so that you don't need to iterate through additional elements unnecessarily.
[2022-08-17 11:34:26]
User785723 - Posts: 58
Thank you

So how does this line (or other part of the code) help to prevent the issue?
Date Time Of Last Edit: 2022-08-17 11:53:00
[2022-08-17 11:56:25]
User907968 - Posts: 838
So how does this (or other prt of the code) help to prevent the issue?

Do you mean the issue with using sc.LastTradePrice?

If so it prevents the issue because you always start at the best bid or best offer (LevelIndex = 0 in the exmaple below, from studies2.cpp) when iterating through the market depth array, you then use the price obtained from the depth data to get the MBO data.

  
for (int LevelIndex = 0; LevelIndex < AskNumLevels; LevelIndex++)
{
  s_MarketDepthEntry MarketDepthEntry;
  sc.GetAskMarketDepthEntryAtLevel(MarketDepthEntry, LevelIndex);

  int ActualLevels = sc.GetAskMarketLimitOrdersForPrice(sc.Round(MarketDepthEntry.Price / sc.TickSize), NumberOfMarketOrderDataElements, MarketOrderData);

  for (int OrderDataIndex = 0; OrderDataIndex < ActualLevels; OrderDataIndex++)
  {
   uint64_t OrderID = MarketOrderData[OrderDataIndex].OrderID;
   t_MarketDataQuantity MarketDataQuantity = MarketOrderData[OrderDataIndex].OrderQuantity;
}

}

Does not need to be a trade for limit order book to move, so it is quite normal that the best bid/best offer can be below/above last trade price.
Date Time Of Last Edit: 2022-08-17 11:59:45

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account