02_Amibroker_ How To Backtest A Single Stock Automatically

Using Amibroker to backtest your trading ideas automatically can be one of the greatest time saving tools you will ever use.  Instead of manually testing your idea, you get the flawless machine to do it and tell you whether you can be successful or not using a particular method.

使用 Amibroker 自动回测您的交易想法可能是您使用过的最节省时间的工具之一。 您无需手动测试您的想法,而是让完美的机器来执行它并告诉您使用特定方法是否可以成功。

 

Luckily with Amibroker and the Amibroker Formula Language (AFL) you can back-test your strategy automatically, over as much history as is available.  Instead of testing taking days or even weeks, you can test your strategy in a matter of minutes with exact results.

幸运的是,借助 Amibroker Amibroker 公式语言 (AFL),您可以在尽可能多的历史记录中自动回测您的策略。 您无需花费数天甚至数周的时间进行测试,只需几分钟即可测试您的策略并获得准确的结果

 

Doesn’t it makes sense to test out the plane before you fly it?  Or test drive the car before you buy it?

在驾驶飞机之前对其进行测试不是很有意义吗? 或者在买车之前先试驾一下?

 

Now we are going to learn how to run an automatic backtest using Amibroker, and input some new Amibroker Formula Language (AFL) to boot.

现在我们将学习如何使用 Amibroker 运行自动回测,并输入一些新的 Amibroker 公式语言 (AFL) 来启动。

 

How To Run A Back-Test On A Stock Using Amibroker AFL

如何使用 Amibroker AFL 对股票进行回测

 

First let’s enter our Amibroker AFL for the back-test.  This is a simple buy on a “20 Day High” strategy, sell on 10 day low, a REALLY rough version of Richard Dennis’ Turtles strategy.

首先让我们进入我们的 Amibroker AFL 进行回测。 这是一个简单的“20 天高点买入,10 天低点卖出策略,是理查德·丹尼斯海龟策略的一个非常粗糙的版本。

 

You could also change the values to be anything you like (for example, a 52 week high / low scenario).  Simply change the 20 for the highest high value you want, and the 10 for the lowest low value you want.

您还可以将这些值更改为您喜欢的任何值(例如,52 周高/低情景)。 只需将 20 更改为您想要的最高高值,将 10 更改为您想要的最低低值。

 

In the top toolbar, go to Analysis > Formula Editor and enter the following code:

在顶部工具栏中,转到分析”>“公式编辑器并输入以下代码:

HI = HHV (C, 20);

LW = LLV (C, 10);

Buy = C >= HI;

Sell = C <= LW;

 

  • Sometimes the code won’t work unless you type it in manually, as copying it from a webpage can bring additional whitespace or hidden characters.

有时,除非您手动输入,否则代码将无法工作,因为从网页复制代码可能会带来额外的空格或隐藏字符。

 

  • You can save this code if you like, then; Go to Tools > Send To Auto Analysis

如果您愿意,可以保存此代码; 转到工具 > 发送到自动分析

 

The Automatic Analysis Window will appear.  Here we will move from left to right and ultimately click our Amibroker Backtest button.

将出现自动分析窗口。 在这里,我们将从左向右移动,最终单击我们的 Amibroker 回测按钮。

  • Under “Apply To”, select “Current Stock” and make sure you are looking at  chart of the stock you wish to backtest.

应用到下,选择当前股票并确保您正在查看要回测的股票的图表。

  • Under “Range”, select “From” and input the dates you wish to backtest the stock for (usually five to 10 years is a good timeframe, and some people believe the more the better).

范围下,选择并输入您想要回测股票的日期(通常五到十年是一个不错的时间范围,有些人认为越多越好)。

  • Under “Settings” in the General Tab, select “Periodicity” > Daily.

常规选项卡的设置下,选择周期性”>“每日

 

Click the Backtest button, and the stock will back test using the method we gave it!

点击回测按钮,该股票将使用我们提供的方法进行回测!

How To See Your Results Quickly And Easily Using “Report”

如何使用报告快速轻松地查看结果

 

Once the back test is complete, click the “Report” button.  The statistics of this method will come up in your Backtest report.  You can see things like the Annual Return, The overall Net Profit, and then your Win Percentage, Loss Percentage, and your average profit and loss per trade.

回测完成后,单击报告按钮。 此方法的统计数据将出现在您的回测报告中。 您可以查看年回报率、总体净利润、盈利百分比、亏损百分比以及每笔交易的平均盈亏等信息。

 

If you click on the “Charts” button up the top of this back-test report, you can see things like your equity curve, your drawdown or Underwater Equity, and your monthly or yearly profit and loss statement.  Just like a real Managed Fund or Hedge Fund.  Pretty cool huh?

如果您点击此回测报告顶部的图表按钮,您可以看到诸如您的净值曲线、您的回撤或水下净值以及您的每月或每年损益表等内容。 就像真正的管理基金或对冲基金一样。 很酷吧?

 

How To See The Buy And Sell Arrows On Your Amibroker Backtest

如何在 Amibroker 回测中查看买入和卖出箭头

So we’ve played with all our data and gasped in awe at the great things we can measure with our stock market system, wouldn’t it be great to see on our chart exactly where we bought and sold?

因此,我们已经研究了所有数据,并对我们可以通过股票市场系统衡量的伟大事物感到敬畏,如果能在图表上准确地看到我们买入和卖出的位置,这不是很棒吗?

Of course it would.

当然会。

So if we go to our chart that is open in Amibroker and right click, we get options like “Parameters” and “Edit Formula”.

因此,如果我们转到 Amibroker 中打开的图表并右键单击,我们会看到参数编辑公式等选项。

 

  • Click on “Parameters”.

单击参数

  • Go to “Axes and Grid” tab

转到轴和网格选项卡

  • Scroll down and select “Show Trading Arrows” > Yes Click OK

向下滚动并选择显示交易箭头”>“单击确定

  • Now if we go back to our Automatic Analysis screen (Analysis > Automatic Analysis), run the backtest then;

现在,如果我们返回到自动分析屏幕(分析 > 自动分析),然后运行回测;

  • Right Click on the stock name (with the details and results) Select “Show Arrows For Actual Trades”

右键单击股票名称(包含详细信息和结果)选择显示实际交易的箭头

 

And you will be able to see a Green buy arrow and a Red sell arrow on your chart where the system bought and sold!

您将能够在系统买入和卖出的图表上看到绿色买入箭头和红色卖出箭头!

 

Amazing stuff!

太棒了!

 

Go And Play

去玩吧

 

This tool is so amazing and powerful, and I have often spent countless hours tweaking a system or method and checking the statistics it brings up.  I hope you enjoy it too, go and play with it and see what you come up with!

这个工具是如此令人惊奇和强大,我经常花费无数的时间来调整系统或方法并检查它带来的统计数据。 我希望你也喜欢它,去玩一下,看看你能想出什么!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值