📄 smoothedroc.java
字号:
package com.jsystemtrader.indicator;
import com.jsystemtrader.platform.*;
/**
* Smoothed Rate of Price Change.
*/
public class SmoothedROC extends Indicator {
private final int maLength, lookBackLength;
public SmoothedROC(long time, QuoteHistory qh, int maLength, int lookBackLength) {
super(time, qh);
this.maLength = maLength;
this.lookBackLength = lookBackLength;
}
public double calculate() {
int lastBar = qh.size() - 1;
double emaNow = new EMA(time, qh, maLength, lastBar).calculate();
double emaThen = new EMA(time, qh, maLength, lastBar - lookBackLength).calculate();
double smoothedRateOfChange = ( (emaNow - emaThen) / emaThen) * 100;
value = smoothedRateOfChange;
return value;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -