charlotte nc
Experience: Advanced
Platform: My Own System
Broker: Optimus
Trading: Emini (ES, YM, NQ, ect.)
Posts: 408 since Jan 2015
Thanks Given: 90
Thanks Received: 1,148
|
Here are a few references that you can easily reverse engineer for your specific need:
Code First:
Protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
{
// TickReplay events only occur on the "Last" market data type
if (marketDataUpdate.MarketDataType == MarketDataType.Last)
{
if (marketDataUpdate.Price >= marketDataUpdate.Ask)
{
Print(marketDataUpdate.Volume + " contracts traded at asking price " + marketDataUpdate.Ask);
}
else if (marketDataUpdate.Price <= marketDataUpdate.Bid)
{
Print(marketDataUpdate.Volume + " Contracts Traded at bidding price " + marketDataUpdate.Bid);
}
}
}
Ninja Trader References: https://ninjatrader.com/support/helpGuides/nt8/en-us/?developing_for__tick_replay.htm
Explanation: Using this code, you can tell every trade that was made at the ask or bid, and you can also see the contracted volume at the ask and bid.
So from a technical perspective all you need to do, is just add this new event handler to your code, and you can aggregate up all the various different transactions into whatever time frame you are looking for. (Tick, Minute, Second, etc.), then feed the results of this to your bar update event, set a flag on your bar update event to clear the market data event (reset back to 0) then start aggregating up the next set of data. You could make this as macro, or granular as you like.
Overview: My interpretation of this data is that as you clear the level 1 resting limit order book you will see the cross between a market order and a limit order at the ask or bid depending on if it was a buy or sell. So to your question about was the trade a market order or limit order, it depends on which side of the transaction you are measuring. To one side it is a limit order and to the other side it is a market order.
Hope this helps. Cool Idea that you are working on. Best of luck!
Ian
|