Setting Position Sizing In Amibroker Formula Language
在 Amibroker 公式语言中设置头寸规模
If you’ve been a part of the stock market for any amount of time, you will know that one of the most important parts to a trading and investment plan is your position sizing.
如果您参与股票市场一段时间,您就会知道交易和投资计划最重要的部分之一就是您的头寸规模。
This video shows us how to add some position sizing rules to any trading system when coding in Amibroker Formula Language (AFL).
该视频向我们展示了在使用 Amibroker 公式语言 (AFL) 进行编码时如何向任何交易系统添加一些头寸规模规则。
How We Enter Our Code:
我们如何输入代码:
- From the main screen in Amibroker, open the formula Editor by going to Analysis > Formula Editor.
在 Amibroker 的主屏幕中,转至分析 > 公式编辑器,打开公式编辑器。
- Type in the following code:
输入以下代码:
SetOption(“MaxOpenPositions”, 20);
SetPositionSize(5, spsPercentOfEquity);
设置选项(最大持仓量,5)
设置位置大小(5,权益百分比)
What This Code Means
这段代码的含义
The code above is setting our maximum open positions to 20 at a time, and our position size per stock to 5 percent of our total equity.
上面的代码将我们的最大未平仓头寸设置为一次 20 个,每只股票的头寸规模设置为我们总股本的 5%。
We can use the “SetOption” command for other things as well – typically if you go through the settings menu in the Automatic Analysis window you can see what they are called, and simply call them the same thing in your code (for example, using our “MaxOpenPositions”).
我们也可以将“SetOption”命令用于其他用途 - 通常,如果您浏览“自动分析”窗口中的设置菜单,您可以看到它们的名称,并且只需在代码中将它们称为相同的东西(例如,使用 我们的“最大未平仓头寸”)。