View Full Version : Example for passing Time/Date as a Parameter
zoltran
04-13-2007, 07:41 AM
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?
NinjaTrader_Ray
04-13-2007, 07:44 AM
As a parameter of a method?
private void (DateTime dateTime)
{
Print(dateTime.ToString());
}
Ray
zoltran
04-13-2007, 01:31 PM
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.
NinjaTrader_Dierk
04-14-2007, 12:15 AM
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
04-14-2007, 05:42 AM
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.
Folls
05-17-2007, 10:24 AM
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
NinjaTrader_Ray
05-17-2007, 10:28 AM
The problem is that you have coded an infinite loop. It should be
set { addContract = value; }
Folls
05-17-2007, 10:32 AM
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