|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 7/30/2010 5:47:58 AM
Posts: 2,
Visits: 9
|
|
I need help in using time functions!
I want to insert in my strategy a time controlled period for strategy to be active.
The following code rises an error: '06:45:00' is not a valid time.
in declaration of the variables
Adesso: TTime;
TradeActive: Integer;
timelimitinf, timelimitsup: String;
in procedure OnCreate
AddStringSetting(@timelimitinf, 'Start Time', '06:45:00'); //setting up the time to place the Entry Orders
AddStringSetting(@timelimitsup, 'End Time', '22:00:00'); //setting up the time to place the Entry Orders
in procedure OnNewCandle
Adesso := Time;
if (Adesso > StrToTime(timelimitinf)) and (Adesso < StrToTime(timelimitsup)) then
TradeActive:=1
else TradeActive:=0;
May anybody help and suggest a correct sintax?
Thank you in advance.
from mh
Edited: 7/23/2010 11:48:41 AM by mh
|
|
|
|
|
Junior Member
      
Group: Forum Members
Last Login: 9/7/2010 5:32:17 AM
Posts: 24,
Visits: 36
|
|
Hi, mh. This script is very similar to what you need. I am sure it will help you. Because you can find here time functions. Best regards, Den
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 7/30/2010 5:47:58 AM
Posts: 2,
Visits: 9
|
|
Thank you Dan!
I've also found that time formats may vary: following code runs ok:
Adesso := Time;
if ((Adesso > StrToTime('06.50')) and (Adesso < StrToTime('11.30')) )
or ((Adesso > StrToTime('13.20')) and (Adesso < StrToTime('18.20')) ) then
TradeActive:=1
else
TradeActive:=0;
from mh
|
|
|
|
|
Forum Member
      
Group: Forum Members
Last Login: 7/16/2011 9:47:02 AM
Posts: 34,
Visits: 192
|
|
| Is it possible place order in a fraction of the minute ? thanks
|
|
|
|