![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
As a parameter of a method?
private void (DateTime dateTime) { Print(dateTime.ToString()); } Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
I see. Sorry, DateTime input params are not supported right now. I suggest e.g. parsing an input string (as per your initial post).
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
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.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Jan 2006
Location: Chicago, Illinois, USA
Posts: 126
Thanks: 0
Thanked 1 time in 1 post
|
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 |
|
|
|
|
|
#7 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
The problem is that you have coded an infinite loop. It should be
Code:
set { addContract = value; }
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Jan 2006
Location: Chicago, Illinois, USA
Posts: 126
Thanks: 0
Thanked 1 time in 1 post
|
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 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|