05_Let‘s Learn Amibroker_ How To Scan For Buy And Sell Signals Using Amibroker and AFL

文章介绍了如何在Amibroker中利用公式语言设定买入和卖出信号,通过设置最高高点和最低低点值,进行市场扫描。用户可以自定义交易系统,然后在自动分析中选择观察列表和时间范围进行扫描,展示最近的交易信号。此外,文章还说明了如何在图表上显示交易箭头以直观呈现买卖点。
摘要由CSDN通过智能技术生成

If you’ve been through our other articles you will already know how to set up a watchlist in Amibroker and Backtest a stock with some simple Amibroker Formula Language.

如果您阅读过我们的其他文章,您就会知道如何在 Amibroker 中设置观察列表并使用一些简单的 Amibroker 公式语言回测股票。

 

But knowing how to scan the market for buy and sell signals is also a great skill to have, and Amibroker makes it extremely easy.

但了解如何扫描市场寻找买入和卖出信号也是一项很棒的技能,Amibroker 使这变得极其简单。

 

Scanning A Watchlist Or Portfolio For Buy And Sell Signals Using Amibroker

使用 Amibroker 扫描观察列表或投资组合以获取买入和卖出信号

First, we need some Amibroker Formula Language to tell us where to buy and sell.  For the purposes of this lesson, we will use a simple highest high / lowest low trading system.  You can use any system you like, provided it has the buy and sell signals put in.  Please note that I do not use this method in my own trading, I am simply using it as an example.

首先,我们需要一些 Amibroker 公式语言来告诉我们在哪里买卖。 出于本课程的目的,我们将使用一个简单的最高高点/最低低点交易系统。 您可以使用任何您喜欢的系统,只要它输入了买入和卖出信号。请注意,我在自己的交易中没有使用此方法,我只是将其用作示例。

  • From the main screen in Amibroker, open the formula Editor by going to Analysis > Formula Editor.

在 Amibroker 的主屏幕中,转至分析 > 公式编辑器,打开公式编辑器。

  • Paste in the following code to Notepad and then Amibroker (or type it in if it doesn’t work):

将以下代码粘贴到记事本,然后粘贴到 Amibroker(如果不起作用,则将其键入):

Uphigh = HHV (C, 90);

downhigh = LLV (C, 40);

Buy = C >= Uphigh;

Sell = C <= downhigh;

Buy  = ExRem (Buy,Sell);

Sell = ExRem (Sell,Buy);

  • The first part sets up our highest high and lowest low values – in this instance a 90 day high and 40 day low.

第一部分设置我们的最高高点和最低低点值——在本例中为 90 天的高点和 40 天的低点。

  • The second part tells Amibroker to use those signals to trigger buy and sell signals.

第二部分告诉 Amibroker 使用这些信号来触发买入和卖出信号。

  • The last part tells Amibroker to only show the first signal triggered by a higher high or low.

最后一部分告诉 Amibroker 仅显示由更高的高点或低点触发的第一个信号。

You can save the code if you like, then send it to the Automatic Analysis by going to Tools > Send To Auto Analysis.

如果愿意,您可以保存代码,然后通过转到“工具”>“发送到自动分析”将其发送到“自动分析”。

Now we need to select the watchlist that we want to scan for our buy and sell signals.  In Automatic Analysis, we will work from left to right.

现在我们需要选择要扫描买入和卖出信号的观察列表。 在自动分析中,我们将从左到右进行工作。

  • Under “Apply to”, select “use filter” and select the watchlist of your choice.

在“应用到”下,选择“使用过滤器”并选择您选择的监视列表。

  • Under “Range” select “last n days” and make the value either 1 or 2 (i.e. the last 1 or two trading days for our signal)

在“范围”下选择“最后 n 天”并将值设置为 1 或 2(即我们信号的最后 1 或 2 个交易日)

  • Click Scan, and it will scan the market for our signals and show the ones with signals from the most recent day.

单击“扫描”,它将扫描市场以查找我们的信号,并显示带有最近一天信号的信号。

 

You Can See The Buy And Sell Arrows On Chart As Well

您还可以在图表上看到买入和卖出箭头

As with our individual stock backtest, we can see the Buy and Sell arrows for the stocks in our portfolio too.

与我们的个股回测一样,我们也可以看到投资组合中股票的买入和卖出箭头。

Simply:

简单地:

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 Scan 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, including the latest buy or sell signal.

您将能够在图表上看到系统买入和卖出的绿色买入箭头和红色卖出箭头,包括最新的买入或卖出信号。

AFL文件是通达信中用于编写自定义指标和策略的文件格式。AFL全称为AmiBroker Formula Language,它是一种类C语言的脚本语言,可以用于编写各种技术指标和交易策略。 AFL文件包含了一些预定义的函数和变量,可以用于获取市场数据、计算指标、执行交易等操作。你可以使用通达信的公式编辑器来编写AFL文件,也可以使用其他编辑器来编写,然后导入到通达信中使用。 以下是一个简单的AFL示例,用于计算移动平均线(MA)指标: ``` AFL /*---输入参数---*/ n := Input("MA周期", 5, 100, 10); /*---计算MA指标---*/ MA:=MA(C,n); /*---绘制MA线---*/ Plot("MA",MA,colorRed,styleLine); ``` 这个AFL文件使用了MA函数来计算移动平均线指标,然后使用Plot函数来绘制MA线。在输入参数中,我们定义了MA周期,可以在使用时进行设置。 除了计算指标外,AFL文件还可以用于编写交易系统和策略。例如,我们可以编写一个简单的交易策略,当收盘价上穿MA线时买入,当收盘价下穿MA线时卖出: ``` AFL /*---策略参数---*/ n := Input("MA周期", 5, 100, 10); /*---计算MA指标---*/ MA:=MA(C,n); /*---买入条件---*/ Buy:Cross(C,MA); /*---卖出条件---*/ Sell:Cross(MA,C); ``` 这个AFL文件使用了Cross函数来判断收盘价和MA线的交叉,从而确定买入和卖出的时机。在使用时,我们可以设置MA周期,来适应不同的市场情况。 总之,AFL文件是通达信中非常重要的文件格式,可以用于编写各种自定义指标和交易策略。如果你想进行更高级的交易分析和策略开发,熟练掌握AFL语言是非常必要的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值