|
最近在尝试编写JForex的自动交易策略,发现一个问题:通过代码和API得出的SMA和ATR的值和图表上显示的不一样。实验了多次都是如此,不知是我哪里弄错了。望有达人指点一二,多谢。
如图中,图表中的ATR200值是0.00165,而代码输出的ATR200值则是0.00138.
附上代码和图表屏幕截图:
...
private Instrument instrument = Instrument.EURUSD;
private Period timeFrame = Period.THIRTY_MINS;
private int timePeriod = 200;
private double Bid, Ask;
...
public void onTick(Instrument instrument, ITick tick) throws JFException {
Bid = tick.getBid(); Ask = tick.getAsk();
double SMA = indicators.sma(this.instrument, timeFrame, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, timePeriod, 0);
double ATR = indicators.atr(this.instrument, timeFrame, OfferSide.BID, timePeriod, 0);
console.getOut().println("Instrument= "+this.instrument+", Time Frame= "+timeFrame+", Bid= "+Bid+", Ask= "+Ask);
console.getOut().println("SMA"+timePeriod+"= "+SMA+", ATR"+timePeriod+"= "+ATR);
} |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|