different MACD values from code and chart

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!

Translate to English Show original

csikosbalint avatar

Hi All,

unfortunately I am still looking for the answer. Can anybody give me some help, please?

orto leave comments

Answers: 2

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

Translate to English Show original
14 Dec. 2013 by

wangdaqing0803 avatar

I have the same problem. And I found jf charts are different than many mt4 charts. What should I do?

orto leave comments

Use this function

indicators.macd(instrument, period, side, appliedPrice, fastPeriod, slowPeriod, signalPeriod, filter, numberOfCandlesBefore, time, numberOfCandlesAfter)

and play with numberOfCandlesBefore parameter.

Translate to English Show original
6 Jan. 2014 by

orto leave comments
Please log in or register to post answer.