Click here to Login




Dynamic Position Sizing in your Trading System

Updated on 2019-04-01





In QuantShare, there are two ways to create dynamic position sizing strategies. The easiest method is using the QS programming language and the advanced one is using the money management tool. This article is about the former method.

If you are not familiar with the QS programming language, we strongly suggest you take a look at this article:
QuantShare Programming Language Tutorial

You also need to learn how to create trading strategies before continuing with this tutorial:
The Ultimate Guide to Create Trading Systems in QuantShare


Dynamic Position Sizing

By default, a trading system will allocate an equal amount to each position. The amount is calculated by taking the strategy equity and dividing it by the maximum number of allowed positions.

If you have 100,000 USD in your portfolio and you set up 5 as number of positions, then QuantShare will buy 20,000 USD worth of shares for the new position.




You can change this logic using a single line in your trading system QS language formula. All you need to do is use the "SetSimPosSize" function and define how you want QuantShare to invest in each new position.

The "SetSimPosSize" has two parameters:
Trade Size: Could be an amount in dollars or a percentage value depending on the second parameter
Position Size Type: The position sizing type or technique to use. Possible values are: _DollarValue, _PercentageOfEquity, _Shares


Simple example to buy a fix dollar amount ($10,000) for each new position:
SetSimPosSize(10000, _DollarValue);

To buy a fixed number of shares (Example: 10 shares) use:
SetSimPosSize(10, _Shares);

To buy 10% of the portfolio equity for each new position use:
SetSimPosSize(10, _PercentageOfEquity);

Of course you can use the QS language to create advanced position sizing techniques. For example, you can instruct QuantShare to buy 50% of equity for SPY and 10% for any other asset. Here is how:
pos = iff(stringequal(name(), "SPY"), 50, 10);
SetSimPosSize(pos, _PercentageOfEquity);



Money Management

For advanced position sizing techniques, you can use the money management tool. This tool allows you to implement C# based scripts that catch different trading events (OnStartSimualtion, OnEndPeriod, OnNewPosition...) and perform different actions such as: Increase the number of shares to be bought, scale-in/out a position...

Here are some examples of position sizing techniques implemented using the money management tool:
5 position sizing techniques you can use in your trading system

And here is how to create a scale-in trading strategy and optimize it (also using the money management script):
Money Management: Scale-in Trading Strategy
Money Management: Optimize the scale-in strategy












no comments (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1449 days ago

Profile Graphs
Posted 1554 days ago

QuantShare
Previous Posts

Lock, Link and Undock your Charts
Posted 2364 days ago

How to Use the Percentage Scale
Posted 2913 days ago


More Posts

Back







QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
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.