copy ta-lib-0.4.0.jar to \groovy-2.5.x\lib\
stock_atr.groovy
import java.util.Arrays;
import java.text.DecimalFormat;
import com.tictactec.ta.lib.*;
/* copy from Core.java
public int atrLookback( int optInTimePeriod )
{
}
public RetCode atr( int startIdx,
int endIdx,
double inHigh[],
double inLow[],
double inClose[],
int optInTimePeriod,
MInteger outBegIdx,
MInteger outNBElement,
double outReal[] )
*/
public class Stock_atr {
public static void main(String[] args){
def filename =null;
int SIZE =0;
if (args.size()==2){
filename = args[0];
SIZE = Integer.parseInt(args[1])-1; // 数据的行数,剔除头行 headline
} else {
println " usage: groovy stock_atr filename int ";
return;
}
// 申明输入参数
double[] inHigh = new double[SIZE];
double[] inLow = new double[SIZE];
double[] inClose = new double[SIZE];
// 初始值
Arrays.fill(inHigh, 0.0);
Arrays.fill(inLow, 0.0);
Arra

本文介绍了一个使用Groovy编程语言实现的股票平均真实波动幅度(ATR)指标计算程序。该程序读取CSV文件中的股票价格数据,包括最高价、最低价和收盘价,然后利用TALib库计算ATR指标。程序详细展示了如何处理数据、调用TALib函数及输出结果。
最低0.47元/天 解锁文章
2118

被折叠的 条评论
为什么被折叠?



