之前有報告過各種資金管理的模型,那時候是用MSA3這個軟體來做模擬和測試的,可是如果MSA3的試用期滿之後,可能就不能再繼續使用了。而在TS forum裡面,有個叫做Hamfon的高手,他把各種資金管理模型都寫成Easy Language了,所以有興趣的朋友可以直接用TS就來做資金管理的模擬和測試了。
他把八種資金管理的模型都寫出來了,分別是:
1 = Fixed Fraction (based on Percentage input, as well as CurrentBalance and Margin)
2 = Fixed Ratio (based on InvDelta, LotSize, CurrentBalance, and OriginalStake)
3 = Percent Risk (based on CurrentBalance, RiskPct and StopLossAmount)
4 = Percent Volatility (based on CurrentBalance and VolatilityPct)
5 = Fixed Lot (always same size)
6 = Fixed Margin Amount (increments/decrements the position size in fixed steps based on CurrentBalance and percentage of Margin)
7 = Fixed Margin Amount with Trailing (same as #6, but also temporarily decreases position size on a drawdown)
8 = Conservative Fixed (calculates based on CurrentBalance related to Margin and DrawDown)
2 = Fixed Ratio (based on InvDelta, LotSize, CurrentBalance, and OriginalStake)
3 = Percent Risk (based on CurrentBalance, RiskPct and StopLossAmount)
4 = Percent Volatility (based on CurrentBalance and VolatilityPct)
5 = Fixed Lot (always same size)
6 = Fixed Margin Amount (increments/decrements the position size in fixed steps based on CurrentBalance and percentage of Margin)
7 = Fixed Margin Amount with Trailing (same as #6, but also temporarily decreases position size on a drawdown)
8 = Conservative Fixed (calculates based on CurrentBalance related to Margin and DrawDown)
而他用了一個簡單的三條移動平均線系統當作他測試進出場的系統,各位可以改寫成用你們自己的進出場系統,再搭配他的資金管理模型,就可以看出各種不同模型對於最終資產的影響。
下面是他原始的文章,裡面有基本的說明,還有每個參數的解說。附加的檔案我放在最下面:
==========================================================
Position sizing is a key element in strategy development yet too often overlooked. With anappropriate trade sizing strategy maximum potential drawdown of a system is understood and used in conjunction with increasing bet size as equity grows...both a must for making the most out of a system... and keeping afloat by minimizing risk. An excellent overview of position sizing can be found in Van Tharp's book 'Trade Your Way To Financial Freedom'.
With help from ebear, I have designed a position sizing Function for TradeStation that allows you to test several position sizing algorithms, and optimize them for particular trading conditions, tickers, timeframes, margins, and capital.
Although these algorithms are just a few of many possibilities, we have found them to be the basis for more complex schemes - and have, in general, tried to stay with the KISS simplicity principle.
We also implemented and tested the Optimal-F algorithm, but discarded it because the position size swings were, in our opinion, excessive, with higher maximum drawdown and risk of ruin.
The attached Function includes the following eight algorithms (with their parameters detailed below). A sample Strategy is also attached. This strategy (which works pretty well!) is a simple 3-moving average "stack" -
that is, we go long when fast and medium MA are both above the slow MA, and when the fast crosses up over the medium MA (stacked upside down for short trade signals). Note that I kept the parameters separate for most of the
algorithms, so that you can optimize them separately. Also, the parameters that are specific to a particular algorithm include that number in the parameter name. Recommended starting values for the Function Input
parameters are given in parentheses - these are the default values in the attached sample Strategy.
1 = Fixed Fraction (based on Percentage input, as well as CurrentBalance and Margin)
2 = Fixed Ratio (based on InvDelta, LotSize, CurrentBalance, and OriginalStake)
3 = Percent Risk (based on CurrentBalance, RiskPct and StopLossAmount)
4 = Percent Volatility (based on CurrentBalance and VolatilityPct)
5 = Fixed Lot (always same size)
6 = Fixed Margin Amount (increments/decrements the position size in fixed steps based on CurrentBalance and percentage of Margin)
7 = Fixed Margin Amount with Trailing (same as #6, but also temporarily decreases position size on a drawdown)
8 = Conservative Fixed (calculates based on CurrentBalance related to Margin and DrawDown)
Here are the parameters for the PositionSizer Function:
AlgorithmNum(1) - specify value 1 through 8 to choose which algorithm to use
OriginalStake(20000) - how much money you start with
MarginAmt(3700) - margin for futures
TradeLotSize(1) - Scaling adjustment - normally 1 for Futures, 100 for stocks
MaxLotSize(100) - trade no more than this many contracts
Factor(1) - level of conservative/aggressive trading
IncludeOpenPL(false) - do we include Profit/Loss from current open position in CurrentBalance?
FixedFracPct#1(0.3) - for Fixed Fraction
InvDelta#2(0.0005) - for Fixed Ratio
RiskPct#3(3.4) - for Percent Risk
StopLossPct#3#4(2) - for Percent Risk and Percent Volatility
VolatilityPct#4(4) - for Percent Volatility
VolatilityScaling#4(2) - for Percent Volatility
FixedLot#5(1) - for Fixed Lot
IncMarginPct#6#7(200) - Percentage of current "base" where we increase the position size
DecMarginPct#6#7(50) - Percentage of current "base" where we decrease the position size
TrailingPct#7(90) - Percentage of current "base" where we temporarily decrease the position size
MaxDrawDownBux#8(500) - Maximum allowed drawdown before changing position size
Comments and suggestions for improving the code are welcome - thanks! I also have other TradeStation strategies, functions, and indicators on my web site athttp://www.hamfon.com/daytrade .
HamFon
HamFon@HamFon.com
========================================================
Easy Language 的檔案放在這裡:
沒有留言:
張貼留言
感謝您的留言