Adding an Index Filter to your trading system has the power to help keep you out of bear markets or severe downward periods in the stock market, by switching off your system as a market turns down.
在您的交易系统中添加指数过滤器可以在市场下跌时关闭您的系统,从而帮助您远离熊市或股市严重下跌时期。
There are many ways to do this, but in this video we show you how to Code a Moving Average Index Filter, that helps increase our gains in a simple trading system.
有很多方法可以做到这一点,但在本视频中,我们向您展示如何编写移动平均指数过滤器,这有助于增加我们在简单交易系统中的收益。
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:
输入以下代码:
Index = Foreign(“XAO”, “C”, True);
IndexMA = MA(Index, 100);
What This Code Means
这段代码的含义
What we are asking Amibroker to do, is to bring in a “Foreign” ticker to our trading system – the ticker we want to use as an Index Filter and its closing price. In our case, it is the All Ordinaries in Australia.
我们要求 Amibroker 做的就是在我们的交易系统中引入一个“外国”股票代码——我们想要用作指数过滤器的股票代码及其收盘价。 在我们的例子中,它是澳大利亚的所有普通人。
We have set it up as an object, or an “Array”, Index, that we can reference back to later in the code. And we do – we use it next in the Moving Average we set up, by calling on a Moving Average of our array, Index.
我们将其设置为一个对象或“数组”索引,我们可以在稍后的代码中引用它。 我们确实这样做了 - 接下来我们在设置的移动平均线中使用它,通过调用数组 Index 的移动平均线。
Obviously you can use this any way you like – it doesn’t have to be with a Moving Average. Test it out for yourself.
显然,您可以以任何您喜欢的方式使用它——不必使用移动平均线。 亲自测试一下。