|
JFOREX-3077 discrepancy between indicator on chart and Tester |
CatturaPip
|
Post subject: JFOREX-3077 discrepancy between indicator on chart and Tester |
Post rating: 0
|
Posted: Wed 22 Dec, 2010, 16:14
|
|
User rating: 0
Joined: Sun 22 May, 2011, 23:43 Posts: 12 Location: Italy, Roma
|
Hi, I'm using a custom indicator in a IStrategy and I noticed that the values of this indicator displayed on chart are different from the values acquired by the IStrategy. My surprise is that such discrepancy happens even with a standard indicator like SMA. As an example, I calculate SMA(9) in one of the two following ways:
// 1st method double fastMA = indicators.sma(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 9, 0);
// 2nd method Object[] fastMA2_obj = indicators.calculateIndicator(instrument, period, new OfferSide[]{OfferSide.BID}, "SMA", new IIndicators.AppliedPrice[]{IIndicators.AppliedPrice.CLOSE}, new Object[]{9}, 0); double fastMA2 = (Double) fastMA2_obj[0];
I verified that fastMA = fastMA2 for every IBar. The problem is that this value differs from the SMA(9) displayed on chart. Usually the difference comes after the 2nd decimal place, but it is still noticeable. Indeed, thanks to this small differences, my strategy ends up opening and closing trades at different times then expected looking at the chart. Any suggestions regarding this discrepancy? Kind regards, Paolo
|
|
|
|
|
API Support
|
Post subject: Re: discrepancy between indicator on chart and Historical Te |
Post rating: 0
|
Posted: Mon 27 Dec, 2010, 11:51
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
|
Vitalhb
|
Post subject: Re: discrepancy between indicator on chart and Historical Te |
Post rating: 0
|
Posted: Wed 29 Jun, 2011, 14:41
|
|
User rating: 0
Joined: Mon 30 May, 2011, 17:47 Posts: 5 Location: BR
|
I have had the same problem with EMA and Bollinger bands. Using the function with the filter parameter solved the problem for the EMA indicator, but Bollinger Bands are still quite different. In JForex, "Filter Flats on weekends" is selected and "Sunday Daily Candles Filtration" is disabled. What should I do to get the same values that I see on the charts? Could you give a tested example for Bollinger Bands?
The code I have used is as follows: public void CalculateIndicators(int shift) throws JFException { long barTime = history.getBar(instrument, UsedPeriod, OfferSide.BID, shift).getTime(); double[][] BBands = indicators.bbands(instrument, UsedPeriod, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 20, 1, 1, IIndicators.MaType.EMA, Filter.WEEKENDS, 1, barTime, 0); double[] EMAs = indicators.ema(instrument, UsedPeriod, OfferSide.BID, IIndicators.AppliedPrice.OPEN, 200, Filter.WEEKENDS, 1, barTime, 0);
EMA = EMAs[0]; BBandHigh = BBands[0][0]; BBandMiddle = BBands[1][0]; BBandLow = BBands[2][0]; }
thanks
|
|
|
|
|
Vitalhb
|
Post subject: Re: discrepancy between indicator on chart and Historical Te |
Post rating: 0
|
Posted: Wed 29 Jun, 2011, 14:46
|
|
User rating: 0
Joined: Mon 30 May, 2011, 17:47 Posts: 5 Location: BR
|
One suggestion: It would be very nice if the indicator functions that do not have the filter as a parameter used the same filter set up at JForex. Otherwise there could be a global filter variable that would be used by all indicator calls that do not have the filter as a parameter.
|
|
|
|
|
API Support
|
Post subject: Re: discrepancy between indicator on chart and Historical Te |
Post rating: 0
|
Posted: Thu 30 Jun, 2011, 13:23
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Vitalhb wrote: I have had the same problem with EMA and Bollinger bands. Using the function with the filter parameter solved the problem for the EMA indicator, but Bollinger Bands are still quite different. In JForex, "Filter Flats on weekends" is selected and "Sunday Daily Candles Filtration" is disabled. What should I do to get the same values that I see on the charts? Could you give a tested example for Bollinger Bands?
The code I have used is as follows: public void CalculateIndicators(int shift) throws JFException { long barTime = history.getBar(instrument, UsedPeriod, OfferSide.BID, shift).getTime(); double[][] BBands = indicators.bbands(instrument, UsedPeriod, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 20, 1, 1, IIndicators.MaType.EMA, Filter.WEEKENDS, 1, barTime, 0); double[] EMAs = indicators.ema(instrument, UsedPeriod, OfferSide.BID, IIndicators.AppliedPrice.OPEN, 200, Filter.WEEKENDS, 1, barTime, 0);
EMA = EMAs[0]; BBandHigh = BBands[0][0]; BBandMiddle = BBands[1][0]; BBandLow = BBands[2][0]; }
thanks How do you test you test your strategy? Do the values differ for testing with live data, historical data or with both?
|
|
|
|
|
Vitalhb
|
Post subject: Re: JFOREX-3077 discrepancy between indicator on chart and T |
Post rating: 0
|
Posted: Fri 01 Jul, 2011, 03:07
|
|
User rating: 0
Joined: Mon 30 May, 2011, 17:47 Posts: 5 Location: BR
|
The values differ for both live data and historical data. I think I have found the problem: it is a bug in the indicators.bbands function. When the MA Type parameter is set to EMA, the values are calculated using SMA, instead of EMA. The other MA types work correctly.
Please, run the attached strategy on a chart with Bollinger Bands (20, 1, 1) for the different MA types and you will see that the plotted values are the same for SMA and EMA MA types. I did not see any effect in changing the filter parameter as well.
Attachments: |
BBandsDiscrepancy.java [4.72 KiB]
Downloaded 466 times
|
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on
this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control
on their content. Anyone accessing this webpage and downloading or otherwise making use of any document,
data or information found on this webpage shall do it on his/her own risks without any recourse against
Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from
the use and/or reliance on any document, data or information found on this webpage.
|
|
|
|
|
|
|
Pages: [
1
]
|
|
|
|
|