Profile Picture

error message

Posted By adiaco 5 Years Ago
Message
Posted Wednesday February 08 2012
I seem to get the following error message all the time. Usually I fiddle with things until it goes away, but I'm stuck this time and I'd really like to understand and get to the bottom of it.

An exception of type System.NullReferenceException was thrown.
Object reference not set to an instance of an object.

It usually happens when I am opening a position with a PositionSettings option. ie.

pos = OpenPosition(settings);

The only reason I know of to get this error is that 'settings' isn't defined, but...

I have initialized:
PositionSettings settings = new PositionSettings();
and have several settings defined:
settings.OrderType = OrderType.Stop;
settings.Size = (long)tradeSize;
...
I know all these settings are getting through to the OpenPosition call because I write them to the console directly before calling OpenPosition.

Any idea why else this error seems to pop up all the time for me?

Thanks a lot,
Anthony

Posted Wednesday February 08 2012
The error should have a stack trace with it. That should help figure out what the issue is. For example:

An exception of type System.NullReferenceException was thrown.
Object reference not set to an instance of an object.
at MySystem.Startup() in d:\RightEdge\Trading Systems\LiveTest\LiveTest.cs:line 17
at RightEdge.Common.SystemBase.Startup(SystemData data)
at MySystemBase.Startup(SystemData data) in d:\RightEdge\Trading Systems\LiveTest\BaseClasses.cs:line 18
at RightEdge.Common.Internal.SystemRunner.Startup()
at RightEdge.Shared.SystemWrapper.InitializeModule(SystemData systemData, SharedSystemRunData runData, ServiceFactory brokerFactory)
at RightEdge.Shared.SystemWrapper.RunSystem(SystemData systemData, SharedSystemRunData runData, ServiceFactory brokerFactory)
at RightEdge.Shared.SystemWrapper.RunSystem(String filename, ServiceFactory brokerFactory, PluginSettings dataStoreSettings)
at RightEdge.Shared.SystemWrapper.RunSystem(String filename, ServiceFactory brokerFactory, PluginSettings dataStoreSettings)
at RightEdge.Shared.TradingModuleWrapper.Run(String filename)
at RightEdge.Shared.TradingModuleWrapper.RunSystem(SharedSystemRunData systemRunData)
at RightEdge.SystemProgress.InitAndRunSystem()

In this case the error happened on line 17 of the trading system (LiveTest.cs).

If the stack trace doesn't help you figure it out, you can post it here and we'll take a look.

Thanks,
Daniel
Posted Wednesday February 08 2012
Here is the stack trace. It points to the OpenPosition call I make.

An exception of type System.NullReferenceException was thrown.
Object reference not set to an instance of an object.
at RightEdge.Common.PositionManager.OpenPosition(PositionSettings options)
at TradingSystems.StrategyBase.OpenPosition(PositionSettings settings) in c:\svn\RightEdge\KalmanCross\StrategyBase.cs:line 150
at TradingSystems.KalmanCross.NewBar() in c:\svn\RightEdge\KalmanCross\KalmanCross.cs:line 88
at MySymbolScript.NewBar() in c:\svn\RightEdge\KalmanCross\MySymbolScript.cs:line 86
at RightEdge.Common.SymbolScriptCollection`1.NewBar()
at MySystemBase.NewBar() in c:\svn\RightEdge\KalmanCross\BaseClasses.cs:line 31
at RightEdge.Common.Internal.SystemRunner.CallSystemNewBar(FrequencyNewBarEventArgs args)
at RightEdge.Common.Internal.SystemRunner.ProcessBarEvents(IEnumerable`1 eventList)
at RightEdge.Common.FrequencyManager.SendPendingBars()
at RightEdge.Common.FrequencyManager.UpdateTime(DateTime dateTime)
at RightEdge.Common.Internal.SystemRunner._tickGenerator_NewBar(Object sender, NewBarEventArgs e)
at RightEdge.Common.TickGenerator.ProcessBar(NewBarEventArgs args)
at RightEdge.Common.Internal.SystemRunner.ProcessBar(NewBarEventArgs newBars)
at RightEdge.Shared.SystemWrapper.RunSystem(SystemData systemData, SharedSystemRunData runData, ServiceFactory brokerFactory)
at RightEdge.Shared.SystemWrapper.RunSystem(String filename, ServiceFactory brokerFactory, PluginSettings dataStoreSettings)
at RightEdge.Shared.SystemWrapper.RunSystem(String filename, ServiceFactory brokerFactory, PluginSettings dataStoreSettings)
at RightEdge.Shared.TradingModuleWrapper.Run(String filename)
at RightEdge.Shared.TradingModuleWrapper.RunSystem(SharedSystemRunData systemRunData)
at RightEdge.SystemProgress.InitAndRunSystem()
Posted Wednesday February 08 2012
figured it out...this time. thanks for the reply.


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems