help on using time functions in a strategy Expand / Collapse
Author
Message
Posted 7/23/2010 6:48:40 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #1803
Posted 7/26/2010 4:44:03 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior 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

  Post Attachments 
Session.act (93 views, 3.66 KB)

Post #1805
Posted 7/30/2010 5:51:29 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #1823
Posted 8/24/2010 9:17:17 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum 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

Post #1888
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin

All times are GMT -5:00, Time now is 11:25am


© 2009 Actforex.com Terms of Use