|
Attention! Read the forum rules carefully before posting a topic.
Try to find an answer in Wiki before asking a question. Submit programming questions in this forum only. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
WMA Filter.NO_FILTER no match shifted WMA-value |
RoadRunner
|
Post subject: WMA Filter.NO_FILTER no match shifted WMA-value |
Post rating: 0
|
Posted: Fri 02 Oct, 2009, 14:41
|
|
User rating: 3
Joined: Wed 18 May, 2011, 16:25 Posts: 331 Location: SwitzerlandSwitzerland
|
WMA with Filter.NO_FILTER does not match shifted WMA-values
I guess, the following is a bug?
I assume, calling WMA without a filter arguments should retrieve the same values as calling WMA with Filter.NO_FILTER. I've done some tests and discovered a time-shift in the results of WMA-values, but maybe I also miss something here?
A) values retrieved through: wma(GBPUSD, FOUR_HOURS, BID, MEDIAN_PRICE, 27, NO_FILTER, 1, <time>, 0)[0]; B) values retrieved through: wma(GBPUSD, FOUR_HOURS, BID, MEDIAN_PRICE, 27, <shift>); C) values retrieved through: wma(GBPUSD, FOUR_HOURS, BID, MEDIAN_PRICE, 27, <time>, <time>)[0];
results retrieved at ticktime=Mon 2009.06.22 00:00:02.490 (GMT): A. <time=Mon 2009.06.22 00:00:00.000>: 1.646520634920635, B. <shift=0>: 1.6466242063492063, C: 1.6466242063492063 A. <time=Sun 2009.06.21 20:00:00.000>: 1.6462562169312167, B. <shift=1>: 1.6458127645502645, C: 1.6458127645502645 A. <time=Sun 2009.06.21 16:00:00.000>: 1.6458127645502645, B. <shift=2>: 1.6453016534391531, C: 1.6453016534391531 A. <time=Sun 2009.06.21 12:00:00.000>: 1.6453016534391531, B. <shift=3>: 1.6447636243386243, C: 1.6447636243386243 A. <time=Sun 2009.06.21 08:00:00.000>: 1.6447636243386243, B. <shift=4>: 1.6441974206349206, C: 1.6441974206349206 A. <time=Sun 2009.06.21 04:00:00.000>: 1.6441974206349206, B. <shift=5>: 1.6436144841269842, C: 1.6436144841269842 A. <time=Sun 2009.06.21 00:00:00.000>: 1.6436144841269842, B. <shift=6>: 1.6430177910052908, C: 1.6430177910052908
The values retrieved through the wma-function with the filter-argument match the values on the chart. That makes sense, as I guess you are using the wma.filter-function to populate the chart.
Could you please have a look into this and let me know your findings? For the moment being, which function returns the correct the values - A) wma.filter OR B)wma.shift / C) wma.fromTo ?
Thanks and best regrads, RR.
|
|
|
|
 |
API Support
|
Post subject: Re: JFOREX-1213: WMA Filter.NO_FILTER no match shifted WMA-value |
Post rating: 0
|
Posted: Mon 05 Oct, 2009, 10:34
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hi, how do you set time for these indicators?
|
|
|
|
 |
RoadRunner
|
Post subject: Re: JFOREX-1213: WMA Filter.NO_FILTER no match shifted WMA-value |
Post rating: 0
|
Posted: Mon 05 Oct, 2009, 11:07
|
|
User rating: 3
Joined: Wed 18 May, 2011, 16:25 Posts: 331 Location: SwitzerlandSwitzerland
|
I was using
long lBarStart = history.getBarStart(period, tick.getTime()) - nShift * period.interval; as well as in other tests long lBarStart = history.getStartTimeOfCurrentBar(period) - nShift * period.interval;
to retrieve the barstarts for the wma-calls.
|
|
|
|
 |
API Support
|
Post subject: Re: JFOREX-1213: WMA Filter.NO_FILTER no match shifted WMA-value |
Post rating: 0
|
Posted: Tue 06 Oct, 2009, 13:24
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
We are not sure about the way you specify your time and shift parameters. We prepared for you test sample, which demonstrates proper usage of all tree wma indicators. Please compare yours shift and time parameters with parameters from sample. package jforex; import java.util.*; import com.dukascopy.api.*;
public class WmaTest implements IStrategy { private IContext context; private IIndicators indicators; private IHistory history; private IConsole console; public void onStart(IContext context) throws JFException { this.context = context; this.indicators = context.getIndicators(); this.history = context.getHistory(); this.console = context.getConsole(); }
public void onAccount(IAccount account) throws JFException { }
public void onMessage(IMessage message) throws JFException { }
public void onStop() throws JFException { }
public void onTick(Instrument instrument, ITick tick) throws JFException { if (instrument == Instrument.GBPUSD){ long time = history.getPreviousBarStart(Period.FOUR_HOURS ,history.getLastTick(Instrument.GBPUSD).getTime()); int i = 1; do { double[] a = indicators.wma(Instrument.GBPUSD, Period.FOUR_HOURS, OfferSide.BID, IIndicators.AppliedPrice.MEDIAN_PRICE, 27, Filter.NO_FILTER, 1, time, 0); double b = indicators.wma(Instrument.GBPUSD, Period.FOUR_HOURS, OfferSide.BID, IIndicators.AppliedPrice.MEDIAN_PRICE, 27, i); double[] c = indicators.wma(Instrument.GBPUSD, Period.FOUR_HOURS, OfferSide.BID, IIndicators.AppliedPrice.MEDIAN_PRICE, 27, time, time); if (a.length > 0 && c.length > 0 && !Double.valueOf(b).isNaN()){ console.getOut().print("A: "+a[0]); console.getOut().print(", B: "+b); console.getOut().println(", C: "+c[0]); } time = history.getTimeForNBarsBack(Period.FOUR_HOURS, time, 2); ++i; } while (i < 10); context.stop(); } } public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { } }
Attachments: |
WmaTest.java [2.03 KiB]
Downloaded 657 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
]
|
|
|
|
|