【发布时间】:2017-03-29 10:26:33
【问题描述】:
我正在使用 Amibroker 版本 6.20.1。我想使用 AFL 代码计算未来 6 个月内某一天股价下跌 X% 的次数。这将需要使用 Ref() 来引用未来的值。
【问题讨论】:
标签: trading algorithmic-trading amibroker
我正在使用 Amibroker 版本 6.20.1。我想使用 AFL 代码计算未来 6 个月内某一天股价下跌 X% 的次数。这将需要使用 Ref() 来引用未来的值。
【问题讨论】:
标签: trading algorithmic-trading amibroker
我想您正在查看过去 6 个月的收盘价,因为没有可以提供未来价格数据的图表软件。以下是我为下面的 AFL 代码所做的假设。 1. 收盘价后 6 个月或 26 周 X 5 天/周 = 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);
}
【讨论】:
您可以倒数过去 20 天内价格从前一天跌至 -1.5% 以下的次数:
N = Sum(ROC(C,1) < -1.5, 20);
您还可以将其转换为未来 20 天内的未来实例,如下所示:
N = Ref(Sum(ROC(C,1) < -1.5, 20), 20);
不过,第二种解决方案在实际交易中不起作用,我敢肯定,你知道。
【讨论】: