Page 1 of 1

Activate the Strategy routine after specified DateTime – how

PostPosted: Sun Oct 30, 2016 5:00 pm
by sztracyh
Here is what I want:
The specified Activate DateTime (call it ActivateDateTime) to be entered in the Parameter input when loading the Strategy.
Use Now() to check against the ActivateDateTime.
Only move on to the strategy routine script after the ActivateDateTime reaches.

I use below in the Parameter:

strategy.parameters:addGroup("Activate DateTime Parameters");
strategy.parameters:addInteger("ActivateYear", "Activate Year", "Specify the Year", 2016);
strategy.parameters:addInteger("ActivateMonth", "Activate Month", "Specify the Month", 10);
strategy.parameters:addInteger("ActivateDay", "Activate Day", "Specify the Day", 1);
strategy.parameters:addInteger("ActivateHour", "Activate Hour", "Specify the Hour", 0);
strategy.parameters:addInteger("ActivateMinute", "Activate Minute", "Specify the Minute", 0);
strategy.parameters:addInteger("ActivateSecond", "Activate Second", "Specify the Second", 0);

And I use below to try to pass-on the above parameters to get the ActivateDateTime:
ActivateDateTime = core.datetime (ActivateYear, ActivateMonth, ActivateDay, ActivateHour, ActivateMinute, ActivateSecond);

But it does not work – the error message is “The first parameter must be a number”.

If I directly enter the number in the assignment (like below), it works:
ActivateDateTime = core.datetime (2016, 10, 1, 0, 0, 0);

Can I get some help on how can I use Parameter to assign a DateTime to the ActivateDatetime?

Appreciate any help.

Tracy Huang