Click here to Login

How to dynamically change the number of positions in a portfolio?

Updated on 2011-03-19 06:12:14

Share |

Using the money management script you can dynamically adjust portfolio settings based on criteria such as annual return, return during the last 30 days, current drawdown, current Sharpe ratio...

In order to limit the maximum number of positions in a portfolio, you can use the function "Portfolio.UpdateCategorySettings".
This function can be accessed in all money management events (OnStartSimulation, OnClosePosition, OnNewPosition, OnEndPeriod and OnEndSimulation).

It has four parameters:
Category: The category that is affected by the change in the percentage of capital allocated and the maximum number of positions. Default categories are "Long" and "Short" (Advanced traders can create their own categories).
Percent to Invest: The percentage of capital to allocate to the above category.
Number of positions: The maximum number of positions to assign to the above category.
Tradubg Order: This is the order that will be used to scale-in and scale-out positions (Force the category to adjust quickly to the new settings). If a "null" is passed then the scale-in and scale-out operations will not be performed.

if(Portfolio.Drawdown < -20)
Portfolio.UpdateCategorySettings("long", 50, 3, null);

no reviews (Log in)

Other how-to articles

How to optimize the number of positions in a trading system

How to dynamically update the settings of an indicator

How to display the number of notes per stock

How to plot the number of stock tweets per day

How to display the number of stocks per day for different RSI groups

How to change volume bar colors when the price closes down

How to perform a basic quantitative analysis using the S&P 500

How to quickly add several positions to your portfolio

How to calculate the average of a time series using the money management tool

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

Copyright 2024
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.