NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 04-09-2010, 10:32 AM   #1
cboat
Member
 
Join Date: Apr 2010
Posts: 50
Thanks: 0
Thanked 0 times in 0 posts
Default Using TimeSpan to return a value

Is there anyway for me to use TimeSpan to return a value for use in a strategy?
cboat is offline  
Reply With Quote
Old 04-09-2010, 10:41 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Welcome to our forums - yes, you can use C# TimeSpan's in your NinjaScript code.

http://www.ninjatrader-support2.com/...ad.php?t=19292
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 04-09-2010, 11:50 AM   #3
cboat
Member
 
Join Date: Apr 2010
Posts: 50
Thanks: 0
Thanked 0 times in 0 posts
Default

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 ;
cboat is offline  
Reply With Quote
Old 04-09-2010, 01:14 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

cboat,

Any runtime errors in your Control Center logs?
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-09-2010, 02:17 PM   #5
cboat
Member
 
Join Date: Apr 2010
Posts: 50
Thanks: 0
Thanked 0 times in 0 posts
Default

Yes I get Error on calling 'OnBarUpdate' methof for strategy 'XXXXX':Object reference not set to an instance of an object.
cboat is offline  
Reply With Quote
Old 04-09-2010, 02:33 PM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Your issue is elsewhere in your code then. Please see this tip: http://www.ninjatrader-support2.com/...ead.php?t=4226

You could try using try-catch blocks to isolate which line is causing you the issues too.
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Optimizing bool/enum/TimeSpan parameters -Swig- Strategy Analyzer 5 12-21-2011 06:58 AM
Volume[1] nothing return Nikoli Indicator Development 4 03-31-2010 08:10 AM
Timespan parameters sequentur General Programming 3 11-04-2009 07:54 AM
How to return value for indicator? cowcool Indicator Development 9 06-01-2009 12:58 PM
Return value is zero billitin Indicator Development 3 10-14-2008 05:15 PM


All times are GMT -6. The time now is 04:37 AM.