Parameters setting for multiple indicators with the same argument names
On Tue, 2011-09-06 at 15:40 +0200, igor_vilcek_external at tatrabanka.sk wrote:
Hi, I've encountered a problem in external parameters setting, in case I want to set parameters for more indicators which posses same argument names (e.g. setting length of multiple different Moving Averages - same name parameter 'n'). I can demonstrate this issue using quantstrat demo maCross (strategy uses "short" and "long" moving average, and my aim is to set length of both averages through 'parameters' argument in applyStrategy):
<...>
Using this input, strategy uses only "50day" Moving Average, for both MA50 and MA200 in 'mktdata'. Is there any way how to implement length of both different moving averages (or other indicators e.g. ROC, BBands,... with same arguments) into 'parameters'?
You have two options, a simple one, and a more complex one. The simple one is for you to generate a brute force set of parameters and loop over them, setting them as variables in your strategy using quote(). see ?expand.grid Or, more flexible but also more complicated, see the two parameterTest demos in the quantstrat package. You can tell the parameter subsystem which slots (indicators) you are applying parameters to, and apply a different distribution to each. Regards, - Brian
Brian G. Peterson http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock