In order to prevent having to manually set various strategy properties using the strategy dialog for each instrument I run my strategy against (which is cumbersome and error prone), I wrote some code that reads the values from within a method in my strategy and assigns the appropriate value to each property based on what the master instrument is. This method is called within the Initialize() method of my strategy.
After I populate the values of these variables, I write them out using Print statements so I can confirm they are set correctly (which, at this point, they are). However, after noticing some odd behaviour, I have discovered that the values I set using my method that is called in Initialize() are later OVERWRITTEN to whatever values are set in the strategy dialog (when I say strategy dialog, I'm referring to the dialog that appears when right click on a strategy in the strategies tab of the Control Center and select 'edit strategy').
My assumption, which is obviously incorrect, was that whatever values you set to properties within Initialize() would remain for the lifetime of the intantiated strategy object, but it seems the framework is calling the set methods on these properties at a later point in time.
So, my question is: When, and under what conditions, does the framework call the set methods of a strategy's properties using the values defined in the strategy dialog?
Note: it's an inefficient workaround, but I found calling my method to set the parameter values each time OnBarUpdate() is called fixes the problem.
Comment