Hi,
Currently, I am able to code certain adaptive strategies that:
1. runs for a selection of tickers (which I provide into the code as list);
2. runs a selected set of strategies (that I provide into code as list);
However, in many cases, I find myself in need to modify the Data range (between which the strategy S will run for a ticker T).
I digged both the forum and the wiki (to the extent their respective search facilities could help) , and as far as I am concerned, the modification to the strategy's xml file (more speficially, the modification of DataRange div of the xml) appears not enough for the RunDonor to run between the desired dates. In fact, it is the Data Range (on the upper-left side of the terminal) that overwrites whatever writes on the strategy's xml file.
To give an example;
1. I modify the strategy's xml file (via code) such that the data range (the strategy should be evaluated between) as ` 1/1/2010 - 1/1/2011` .
2. Meanwhile, the Data range option (on the upper-left of the terminal) is left as `1/1/2010-1/1/2014`.
3. When the code (that includes one RunDonor method) runs, the result is 471,435.
4. I modify the strategy's xml file (via code) such that the data range (the strategy should be evaluated between) as ` 1/1/2011 - 1/1/2012` .
5. Meanwhile, the Data range option (on the upper-left of the terminal) is left as `1/1/2010-1/1/2014`.
6. When the code (that includes one RunDonor method) runs, the net profit of the strategy returns as, 471,435.
7. When I run manually the strategy, with a date range of `1/1/2010-1/1/2014`, the net profit of the term is, 471,435.
8. Yet, when I open the XML file, I see there that the data range (as presented on the strategy's xml file) is, `1/1/2010-1/1/2012`.
9. So, I realized that modifying the xml file of the strategy (for data range purposes) is not the way to set programmatically the Data Range of the backtesting.
**
My Question is:
My hunch is that, I should be using ' SETGLOBAL` , `GETGLOBAL` methods to set the data range of the back-testing. On the contrary, modifying the strategy xml is not enough, and not the appropriate way to achieve programmatic control of the data range.
So, Could you please, provide me some code examples on Data range modifications, or, provide me some links that I can dig the matter myself?
I somehow developed some coding base to deal with the multi-asset strategies, and now, I am after to extend this to multi-time range.
Thanks, again, for the time and consideration,
Aykut Saribiyik
Size:
Color:
The specified Data Range controls the base set of data and is set manually. The data loading option saved in a script's xml file is used when the Strategy is opened AND Preferences > Advanced Options > Data Range is checked. That's the design and there isn't a supported programmatic way to change that.
You can also use Workspaces to open different Data Ranges for the same script since these are saved with the Workspace.
Size:
Color:
When you modify most any XML files while Wealth-Lab is running, the changes will be picked up after restart. This is why it will not work. Like Cone said, modifying the date range programmatically is not supported in WealthScript. Consequently, no examples exist and you're trying it at your risk so to say.
Looking at the C.Components code, however, I think there's one modification that might work out: try tweaking the
ExecuteDonorStrategy routine - the new name of the old
runDonor method. You can find it in the file ..\ExtensionMethods\PortfolioEquityEx.cs:
CODE:
Please log in to see this code.
The idea is to modify the Bars object itself (for SSB, single symbol backtest) or the collection of Bars objects (for MSB, multi-symbol backtest). Off the top of my head, there doesn't seem to be a convenient other way.
Size:
Color:
QUOTE:
You can also use Workspaces to open different Data Ranges for the same script since these are saved with the Workspace
So, leaving this ambition aside, I will continue to do my `data range loop` manually, but, as Cone advised, one wiser move would be to save the same workspace setup with alternative data ranges.
Thank you Cone and Eugene,
Best regards,
Aykut
Size:
Color: