The body of the function is:
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);
}
if (e.MarketDataType == MarketDataType.Last)
{
Last = e.Price;
}
public ActualMarketData()
{
Last = 0.0;
}
public double Last { get; private set; }
function Out() is this (It is called many times before the point of crash in OnMarketData):
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());
}
}
**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.

Comment