0

我正在使用 Amibroker ver6.20.1。我想使用 AFL 代码计算未来 6 个月内某一天股价下跌 X% 的次数。这将需要使用 Ref() 来引用未来值。

https://www.amibroker.com/guide/afl/ref.html

4

2 回答 2

1

我想您正在查看过去 6 个月的收盘价,因为没有图表软件可以提供未来的价格数据。以下是我为下面的 AFL 代码所做的假设。1. 过去 6 个月的收盘价或 26 周 X5 天/周 = 130 天 2. 比较每日收盘价的 X% 3. 股价下跌即昨天的收盘价 > 今天的收盘价

// BarCount is the number of element in Close array.
// Array element start from 0 to BarCount - 1.
// Create Close_price[i] array because Amibroker does not allow Close[i] in an If statement.
// X% is set to 15%.
// Run this AFL in Exploration and select Apply To : All Symbols, From to Date : Current date of your database
Close_price=Close;
Filter = 0;
x=0.05;
j=0;
if (BarCount >= 130) { /* Scan those stocks with at least 6 months data. */
for (i = BarCount - 130; i<BarCount-1; i++){
	if (Close_price[i] > Close_price[i+1] and (1-Close_price[i+1]/Close_price[i])>0.15){
		Filter = 1;
		j++;
		}
}
AddColumn(j,"# of time drop more than 5%",1.0);
}

于 2017-10-17T01:42:19.783 回答
-1

您可以倒数过去 20 天内价格从前一天跌至 -1.5% 以下的次数:

N = Sum(ROC(C,1) < -1.5, 20);

您还可以在接下来的 20 天内将其转换为未来的实例,如下所示:

N = Ref(Sum(ROC(C,1) < -1.5, 20), 20);

第二种解决方案在实际交易中不起作用,我敢肯定,你知道的。

于 2017-12-16T23:02:55.960 回答