Hey guys,
Do you think there is any way to store and then load different predefined sets of Parameter values for my formula?
I want to set up my formula Parameters and then store this preset as "Set1", then change some values and store as "Set2". So that in the future by choosing between these two presets I could quickly and without mistakes switch to Set1 or Set2.
As I understand there is no built-in solution and this should be done manually via code.
What would be your suggested course of actions?
Thank you @travick for your advice.
We are using 2 "presets" out of 3 and frequently switch between them. Also, we still keep adding/changing different features. The formula is in active development atm.
We've introduced quite a few Params and setting up formula became a risky endeavor. As so easy to make a mistake.
It would be fantastic if I could just switch presets within the Parameters window but I do realize it's easier said than done.
I suspect that in our case it will be even more difficult to implement your approach (as have to maintain even more code with every update).
I've been thinking if there is an easy way to write all params to a text file to read them later.
But seems that this will bring heaps of maintenance as well.
Thank you nevertheless.
You could share a specific scenario in your case but you then need to see the frequency among others things.
Read/writing to files may not be the most efficient, AFAIK, the fastest way would be when the values are embedded in the code itself.
If you are talking about parameters that are being computed on the fly, then that's another case but using Param* wouldn't be appropriate if you need them to also appear in the Parameter Window.
Edit: Also, I don't think its a good idea to use the model code I posted but replace the normal variables as Param fields. Its a nested structure but i'm sure TJ would object to that implementation.
I get what you are hinting at from the first post, but there isn't a feature yet where you can have a parent parameter and load a group of sub-parameters in the window based on that.
In our case parameters are just a way for a user to configure formula before the trade starts. It's done once and we don't touch anything after that.
The main discomfort appears when we have to switch from "Set1" to "Set2" or "Set3".
Or when there is an update to a formula file issued, then values are set to "default" and we set up all values by hand.
/// THIS is supposed to be an INCLUDE FILE with sample name "_ParamSet.afl"
/// File has to be put to "...\Formulas\Include" (for example)
/// Read more about include files here
/// @link https://www.amibroker.com/guide/afl/_include.html
// Set param set per row
matstr = "{{10,3,3}," + // Set1
"{15,4,3}," + // Set2
"{20,5,5}}"; // Set3
mat = MxFromString(matstr);