Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on calling 'OnMarketData' method for strategy

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

    Error on calling 'OnMarketData' method for strategy

    I have this strange error, that occurs sporadically on various days for Replay Mode.

    The body of the function is:
    Code:
    protected override void OnMarketData(MarketDataEventArgs e)
    		{
    			if (m_actualMarketData == null)
    			{
    				Out("m_actualMarketData == null");
    				throw new InvalidOperationException("m_actualMarketData == null");
    			}
    			if (e == null)
    			{
    				Out("MarketDataEventArgs == null");
    				throw new InvalidOperationException("MarketDataEventArgs == null");
    			}
    			if (e.MarketDataType == null)
    			{
    				Out("e.MarketDataType == null");
    				throw new InvalidOperationException("e.MarketDataType == null");
    			}
    			m_actualMarketData.OnMarketData(e);
    		}
    ActualMarketData.OnMarketData is:
    Code:
    if (e.MarketDataType == MarketDataType.Last)
    				{					
    					Last = e.Price;
    				}
    ActualMarketData constructor is:
    Code:
    public ActualMarketData()
    			{
    				Last = 0.0;
    			}
    ActualMarketData.Last is a property:
    Code:
    public double Last { get; private set; }
    Update:
    function Out() is this (It is called many times before the point of crash in OnMarketData):
    Code:
    private void Out(string msg)
    		{
    			if (!EnableLog || msg == null)
    			{
    				return;
    			}
    
    			string line = string.Empty;
    
    			if (CurrentBar > 0)
    			{
    				line = string.Format("{0:yyyy-MM-dd HH:mm:ss}:{1}", Time[0], msg);
    			}
    			else
    			{
    				line = msg;
    			}
    
    			Print(line);
    			try
    			{
    				System.IO.File.AppendAllText(m_filename, line + System.Environment.NewLine);
    			}
    			catch (Exception ex)
    			{
    				Print("Cannot log to " + m_filename + ": " + ex.ToString());
    			}
    		}
    The error I get:
    **NT** Error on calling 'OnMarketData' method for strategy 'ABC: Object reference not set to an instance of an object.

    How could that be possible?

    Thank you.
    Last edited by alex.nt; 11-21-2013, 01:50 AM.

    #2
    Alex, would not see anything standing out, best practice in those cases would be chasing the issue down and with standard C# try / catch.

    Comment


      #3
      Traces contain this:
      2013-11-21 01:25:27:233 Cbi.Globals.ProcessEventArgsInThreadContext, exception caught: Object reference not set to an instance of an object.: MarketDataEventArgs: Instrument='ES 12-13 Globex' Type=Bid Price=1744.25 Volume=506 Time=22/10/2013 9:38:46 AM

      Comment


        #4
        Thanks Alex, we would need to reproduce it here on our end if possible. Do you see this consistently on replay data for the ES on Oct 22nd?

        Would you mind sending us your replay data file and script to support so we could further look into it and consult with dev?

        Comment


          #5
          Thank you for your reply.

          Unfortunately the issue appears to be very sporadic, and it only reproduces itself for one client, so I am limited in terms of debugging.

          We will continue monitoring this, if the issue occurs above the acceptance level we will send you the script.

          Comment


            #6
            Thanks Alex, sounds good. Please keep us in the loop.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by charlesugo_1, 05-26-2026, 05:03 PM
            0 responses
            66 views
            0 likes
            Last Post charlesugo_1  
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            149 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            162 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 05-10-2026, 08:12 PM
            0 responses
            99 views
            0 likes
            Last Post CarlTrading  
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            286 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Working...
            X