0

I am using Amibroker. I would like to get the yearly gain of last 2 years using AFL. The yearly gain is defined as price gain on last date of year in December compared to first date of year in January. One way to get this is to view the chart in yearly mode. However, I want the yearly returns to be obtained in AFL.

4

1 回答 1

1

由于您没有要显示的代码,因此可以从这里开始。

b = TimeFrameGetPrice( "C", inYearly, -1 );
v = TimeFrameGetPrice( "C", inYearly, -2 );
change = ((b-v)/v)*100
printf("   = "+WriteVal(b)+"   = "+Writeval(v)+"  = "+WriteVal(change));

如果您将其放在 Guru 评论中,这显示了过去一年的变化率。

您应该能够计算出上一年的数据,然后将输出打印到图表中并把它全部弄好(使用 % 符号、不同的颜色等)。查看 TmeFrameCompress 和 Expand,以获取来自不同时间范围的数据,使用 PlotText 函数绘制输出。

于 2017-06-07T01:48:38.123 回答