Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Confused by output of onMarketData

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_ChrisL
    replied
    Hello Cilla,

    Thank you for your reply.

    Viewing the T&S window will show you that it's possible for multiple trades to occur at a given bid/ask price and not necessarily change the price instantly. This is why we offer the Calculate property of OnPriceChange in contrast to OnEachTick. A single tick of a market doesn't guarantee a price change, so that could improve the performance of your script because it calls OnBarUpdate less often.

    Please let me know if I can assist further.

    Leave a comment:


  • Cilla
    replied
    Hi Chris - thanks for your answer.

    I've looked at the T&S window and that appears to report the same stream of data that my code does, but with some timestamp information included. Are you saying that some trades can occur at e.g. the ask without affecting the ask volume, even though the ask price stays the same?

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    Hello Cilla,

    Thank you for your post and welcome to the NinjaTrader forum!

    When you come across the Last MarketDataType that will be the volume and price the stock or commodity was actually traded at. Not all volume on either the bid or ask side of the market is guaranteed to be filled. This can be visualized with the T&S window. The current bid and ask volume can be seen at the top and there is a stream of trades that are occurring in real time where the volume "trickles" in.

    Please let me know if I can assist further.

    Leave a comment:


  • Cilla
    started a topic Confused by output of onMarketData

    Confused by output of onMarketData

    Hi

    I'm trying to understand some of the output of OnMarketData in which I think I see more traded volume at the Ask than available volume at the Ask. I ran the following code against YM 06-19 future:

    protected override void OnMarketData(MarketDataEventArgs e)
    {
    if (e.MarketDataType == MarketDataType.Last)
    {
    Print("Last: " + e.Volume + " @ " + e.Price);
    }
    else if (e.MarketDataType == MarketDataType.Ask) {
    var diff = e.Volume - lastVolAtAsk;
    Print("Ask: " + diff + " to " + e.Volume + " @ " + e.Price);
    lastVolAtAsk=e.Volume;
    }
    else if (e.MarketDataType == MarketDataType.Bid) {
    var diff = e.Volume - lastVolAtBid;
    Print("Bid: " + diff + " to " + e.Volume + " @ " + e.Price);
    lastVolAtBid=e.Volume;
    }
    }

    The output I don't understand:

    Ask: -1 to 15 @ 25989
    Bid: 1 to 5 @ 25988
    Bid: 1 to 6 @ 25988
    Bid: 1 to 7 @ 25988
    Ask: -1 to 14 @ 25989
    Bid: 1 to 8 @ 25988
    Bid: -1 to 7 @ 25988
    Ask: -1 to 13 @ 25989
    Bid: -1 to 6 @ 25988
    Last: 1 @ 25989
    Last: 1 @ 25989
    Last: 1 @ 25989
    Last: 14 @ 25989

    Ask: -7 to 6 @ 25990
    Bid: 1 to 7 @ 25988
    Bid: 1 to 8 @ 25988
    Ask: 1 to 7 @ 25990
    Bid: 1 to 9 @ 25988
    Bid: -1 to 8 @ 25988

    So, it looks to me like there were 17 contracts traded at the Ask (25989) when there was only an ask volume of 13 available.

    Please could someone help me make sense of this.

Latest Posts

Collapse

Topics Statistics Last Post
Started by halgo_boulder, 04-20-2024, 08:44 AM
2 responses
21 views
0 likes
Last Post halgo_boulder  
Started by mishhh, 05-25-2010, 08:54 AM
19 responses
6,189 views
0 likes
Last Post rene69851  
Started by gwenael, Today, 09:29 AM
0 responses
5 views
0 likes
Last Post gwenael
by gwenael
 
Started by Karado58, 11-26-2012, 02:57 PM
8 responses
14,830 views
0 likes
Last Post Option Whisperer  
Started by Option Whisperer, Today, 09:05 AM
0 responses
2 views
0 likes
Last Post Option Whisperer  
Working...
X