PureBytes Links
Trading Reference Links
|
Hello, hoping someone can point out a good method for incrementing dates. I am currently trying to build a basic Walk-Forward engine that does an Optimization on In-Sample (IS) data using one formula, followed by an Optimization on Out-Of-Sample (OOS) data using a second formula.
This is different than AB's built-in WF engine, which performs an Optimization, followed by a Backtest using only one formula.
Anyway, I am currently stuck right at the beginning, trying to figure out a sensible way to increment dates. This is what I have so far:
// datenum format: 10000 * (year - 1900) + 100 * month + day, // so 2001-12-31 becomes 1011231 and 1995-12-31 becomes 951231
BegISdate = 1031201; EndISdate = 1090201; StepIS = 100;
BegOOSdate = 1050101; EndOOSdate = 1090301; StepOOS = 100;
Formula1 = "F:\\formula1.afl"; Formula2 = "F:\\formula2.afl"; Database = "F:\\AB Databases\\MyDB"; Settings = "F:\\My Settings.ABS";
for (FromISdateNum = BegISDate; FromISdateNum <= EndISdate; FromISdateNum = FromISdateNum + StepIS) {
AB = CreateObject("Broker.Application");
// Etc. .........
Now the above won't exactly work because simply adding 100 to a datenum will not allow the datenum to correctly roll over from December to January. For example, incrementing 1031201 by 100 yields 1031301 instead of 1040101.
I know I can first convert the datenum to a string, then build a parser that splits the datenum apart and analyzes the last four digits, converting 1301 to 0101, then reconstitute the string and reconvert to a datenum again. But that all feels rather convoluted.
Is there an easier way to increment dates in AFL? I've searched the help manual and can't seem to find anything. What if I first converted to DateTime format? Is there an easy way to step through that format month by month?
Any pointers much appreciated.
And when I complete the WF Opt-Opt engine, I will be happy to post it here, in case anyone else has a need for it.
Thanks!
__._,_.___
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
__,_._,___
|