PDA

View Full Version : Using TimeSpan to return a value


cboat
04-09-2010, 10:32 AM
Is there anyway for me to use TimeSpan to return a value for use in a strategy?

NinjaTrader_Bertrand
04-09-2010, 10:41 AM
Welcome to our forums - yes, you can use C# TimeSpan's in your NinjaScript code.

http://www.ninjatrader-support2.com/vb/showthread.php?t=19292

cboat
04-09-2010, 11:50 AM
This is what i have so far and It seems to not be returning anything to me.
A little bit of help would go a long way.

DateTime startTime = DateTime.Now;
tradeTime = DateTime.Now.Subtract(startTime).TotalMilliseconds ;

NinjaTrader_Josh
04-09-2010, 01:14 PM
cboat,

Any runtime errors in your Control Center logs?

cboat
04-09-2010, 02:17 PM
Yes I get Error on calling 'OnBarUpdate' methof for strategy 'XXXXX':Object reference not set to an instance of an object.

NinjaTrader_Josh
04-09-2010, 02:33 PM
Your issue is elsewhere in your code then. Please see this tip: http://www.ninjatrader-support2.com/vb/showthread.php?t=4226

You could try using try-catch blocks to isolate which line is causing you the issues too.