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-13-2007, 06:41 AM   #1
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

What is the best way to pass a time or date as a parm ?
Do you use a string and then parse it out?
Or is there a better way?
zoltran is offline  
Reply With Quote
Old 04-13-2007, 06:44 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

As a parameter of a method?

private void (DateTime dateTime)
{
Print(dateTime.ToString());
}


Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-13-2007, 12:31 PM   #3
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Thanks Ray

No, I was meaning as an input parm to a Indicator or Strategy.
For example, to set the times when a strategy should trade.

I do it now by hard coding the times in the code.
zoltran is offline  
Reply With Quote
Old 04-13-2007, 11:15 PM   #4
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

I see. Sorry, DateTime input params are not supported right now. I suggest e.g. parsing an input string (as per your initial post).
NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-14-2007, 04:42 AM   #5
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

Another thought: if you want to set intra day limits like "begin of critical period" = 9:45 and "end of critical period"= 15:30 you could of course go with integers like 945 and 1530 and convert them to hours and minute values.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 05-17-2007, 09:24 AM   #6
Folls
Senior Member
 
Join Date: Jan 2006
Location: Chicago, Illinois, USA
Posts: 126
Thanks: 0
Thanked 1 time in 1 post
Default

Could you please give me an example of using a string as an input in a strategy? I used the following and it crashed Ninja.

in variables:

private string addContract = "ER2 06-07";

in properties:

[Description("")]
[Category("Parameters")]
public string AddContract
{
get { return addContract; }
set { AddContract = addContract; }
}

in initialize():

Add(addContract, PeriodType.Second, 15);

Thanks,

Folls
Folls is offline  
Reply With Quote
Old 05-17-2007, 09:28 AM   #7
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

The problem is that you have coded an infinite loop. It should be

Code:
set { addContract = value; }
NinjaTrader_Ray is offline  
Reply With Quote
Old 05-17-2007, 09:32 AM   #8
Folls
Senior Member
 
Join Date: Jan 2006
Location: Chicago, Illinois, USA
Posts: 126
Thanks: 0
Thanked 1 time in 1 post
Default

Sorry. Thanks for your help. It must be frustrating at times for you to get non-programmers posting programming questions. There is definitely a learning curve. I think a few more weeks and I'll be fine.

Folls
Folls 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


All times are GMT -6. The time now is 01:51 PM.