Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Running market Replay. in onMarketUpdate function, sometimes e.price is 0, why?

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

    Running market Replay. in onMarketUpdate function, sometimes e.price is 0, why?

    Wondering what the various return scenarios are for the price variable of the MarketDataEventArgs type parameter

    https://ninjatrader.com/support/help...marketdata.htm
    & https://ninjatrader.com/support/help...tdataeventargs. htm

    ...both show price is one of the fields returned but my scripts are occasionally telling me they're getting returned price = 0. What sort of MarketDataEvent returns price 0?

    Print statements (Print("In MarketUpdate function e.price = "+e.Price);) generated the following output:

    Ask = 72.72 7
    In MarketUpdate function e.price = 72.72
    Bid = 72.71 1
    In MarketUpdate function e.price = 72.71
    Last = 72.72 1
    In MarketUpdate function e.price = 72.72
    In MarketUpdate function e.price = 0
    Ask = 72.72 6
    In MarketUpdate function e.price = 72.72
    Last = 72.72 1
    In MarketUpdate function e.price = 72.72
    In MarketUpdate function e.price = 0
    Ask = 72.72 5
    In MarketUpdate function e.price = 72.72
    Ask = 72.72 6
    In MarketUpdate function e.price = 72.72
    Bid = 72.71 2
    In MarketUpdate function e.price = 72.71​
    Last edited by markdshark; 04-09-2023, 10:43 AM.

    #2
    From the help:
    MarketDataType Possible values are:

    MarketDataType.Ask

    MarketDataType.Bid

    MarketDataType.DailyHigh

    MarketDataType.DailyLow

    MarketDataType.DailyVolume

    MarketDataType.Last

    MarketDataType.LastClose (prior session close)

    MarketDataType.Opening

    MarketDataType.OpenInterest (supported by IQFeed, Kinetick)

    MarketDataType.Settlement

    You're probably either seeing one of those other types, or you are seeing a situation where the bid or ask are unavailable.
    Source: https://ninjatrader.com//support/hel...aeventargs.htm
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Thank you. With your reply a bit of rethinking clarified that for me. I was wrongly assuming every market event would return a price but now I see that even if a price is returned it might be something completely different from what my code is looking for.

      Comment


        #4
        Hello markdshark,

        Thanks for your post.

        As QuantKey_Bruce stated, OnMarketData() MarketDataEventArgs contains different MarketDataTypes and you may be accessing one of those other types or see an event where the bid or ask are not available.

        To get the Price of a specific MarketDataType, you could create a condition that checks if say marketDataUpdate.MarketDataType == MarketDataType.Last and print out the Price in that condition.

        See the sample code on this help guide page: https://ninjatrader.com/support/help...aeventargs.htm

        Please let me know if I may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        64 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        139 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X