Click here to Login

                                                   Reuse optimization parameters from Strategy script in Money Mgmt


2015-04-21 15:20:07

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)

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.


2015-04-22 03:13:49


Hi Kiran,

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?

2015-04-22 10:01:59


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?


2015-04-23 02:38:53


Hi Kiran,

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.

2015-04-23 23:33:49


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");

2015-04-24 02:44:17


At any moment in the script editor, you can use CONTROL+SPACE shortcut to display possible values.

Here is what you need to type for example:

SetSimPosSize(10, _PercentOfEquity); // To buy 10% of equity

No more messages


No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"


Trading Items
Investing in stocks using the Kelly criterion money management st...
Correlation Filter Money Management Strategy
Long strategy created with the money management tool
Averaging Down Money Management Strategy
Return per Bar Stop - Money Management Strategy

How-to Lessons
How to run a screen or a watchlist from a script
How to generate buy/sell signals from a trading system
How to get trading orders from a portfolio programmatically
How to calculate the average of a time series using the money man...
How to get stocks for a particular index using the global script

Related Forum Threads
Price reference from Money Management Script
Place a profit stop through Money management strategy
Script to remove Symbols from an Index
Money Management script and exit options in the wizard
Can a Money Management script access a custom function?

Blog Posts
How to Backtest a Strategy from a Chart
Money Management: Optimize the scale-in strategy
Create a trading strategy using the money management tool - Part ...
Money Management: Scale-in Trading Strategy
Create a trading strategy using the money management tool - Part ...

Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2021
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

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.