Hi all! I am newbie for jForex and I think I have missed something, please help!
I have started a ITesterClient and draw IChar(s) on a JPanel. I add an MACD indicator this way:
if ( c.getInstrument().equals(Instrument.EURUSD)) {
c.add(context.getIndicators().getIndicator("MACD"), new Object[] { 12, 26, 9 });
}
Later for the MACDSample strategy I need MACD History value. I calculate the values onBar() this way:
MacdCurrent = indicators.macd(instrument, Period.ONE_HOUR, OfferSide.BID,
IIndicators.AppliedPrice.CLOSE, 12, 26, 9, 0);
MacdPrevious = indicators.macd(instrument, Period.ONE_HOUR, OfferSide.BID,
IIndicators.AppliedPrice.CLOSE, 12, 26, 9, 1);
And print them out (docs: "returned in the following order: 'MACD', 'MACD Signal', 'MACD Hist' "):
label.setText("act: " + MacdCurrent[2] + " pre: " + MacdPrevious[2],
new Font(Font.MONOSPACED , Font.PLAIN, 12));
label.setColor(Color.BLACK);
if ( c.getInstrument().equals(Instrument.EURUSD)) {
c.add(label);
}
And I can see the following result:
http://postimg.org/image/5vcw9hnmf/
[url=http://postimg.org/image/5vcw9hnmf/][img]http://s23.postimg.org/5vcw9hnmf/macd_hist.jpg[/img][/url]
As you can see the actual hist value on the chart is -0.0484 and the act calculated value is -2.981E-5. The signum is ok both for act and pre but values seems odd to me. How is this possible?
Thx for your help!
It's quite hard to provide you a definite answer without looking at charts. Maybe Dukascopy Support Team can help you in this regard.
thanks
Use this function
indicators.macd(instrument, period, side, appliedPrice, fastPeriod, slowPeriod, signalPeriod, filter, numberOfCandlesBefore, time, numberOfCandlesAfter)
and play with numberOfCandlesBefore parameter.