How do i reuse optimization parameters from the Strategy script (e.g. N-bar Stop "hold Period", RSI period used to rank stocks for Buy signals, etc.) in my Money Mgmt script?
I came across this blog below that describes adding new opt parameters in Money Mgmt, but this approach creates redundant optimization parameters, which is disruptive (e.g. 2 sets of RSI periods, one used for Money Mgmt and another in Strategy script ranking) http://www.quantshare.com/sa-491-money-management-optimize-the-scale-in-strategy
Any code sample that shows how i can reuse the opt parameters from the Strategy script (e.g. RSI period) and Strategy GUI (e.g. N-bar Stop period) in the Money Mgmt script would be helpful.
Currently, there is no built-in function to get strategy variables within the money management script.
Why do you need to use the same RSI again in the money management script?
e.g. I use the perf(close,per) as a ranking function and as a filter (perf>0) in the Strategy script, and also use perf(close,per) for dynamic "max-perf" position sizing in Money Mgmt script, so the Buy Orders are position-sized proportional to perf(close, per).
In this example, I would need to optimize for "per".
- Any work-around to address this?
You can use "SetSimPosSize" to dynamically adjust positions within the strategy script.
Otherwise, you will have to create a custom function (Tools -> Create Functions) that is called from the strategy. This function would save the parameter value in a global variable using the "Global" class. That same variable can be retrieved later from the MM script using the same "Global" class.
Thanks,
I have a rank-based rebalancing system and want to set my position size weighted inversely proportional to the rank. i.e. in a portfolio of 5 positions, Rank1 is weighted 4/10, Rank2=3/10, and so on.. (Below is the code)
- What are the parameters in the SetSimPosSize (is it % of portfolio equity or # of shares)? Couldn't find documentation on this function.
- How do i determine the portfolio equity and the stock price in the Strategy script below?
- Also, in the scenario where only 1 Sell is triggered by Stop rule (instead of rebalancing the entire portfolio), how do i determine % of portfolio in cash, to determine the # of open positions to fill with Buy orders?
/////Strategy script to weigh position size inverse to rank...
pos = 8;
rank1= comp(<ranking function>, "rank", 1, 1);
SetSimPosSize((pos-rank1)*2/pos*(pos-1)*<Portfolio equity>/<stock-price>,"LONG");
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.