Dukascopy
 
 
Wiki JStore Search Login

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.

Different results using instrument in JForex client to stand-alone API
 Post subject: Different results using instrument in JForex client to stand-alone API Post rating: 0   New post Posted: Thu 29 Mar, 2012, 15:07 

User rating: 5
Joined: Thu 29 Mar, 2012, 15:00
Posts: 19
Hello,

I've been messing around using a custom RSX Indicator that I found on these forums. Obviously I'm doing something wrong though because although I'm using the same inputs I'm getting outputs from the stand-along API that are similar but different to those from the stand-alone.

I've been exporting the indicator results for the same instrument, period and over the same time period to a CSV and then drawing a graph. As well as my source code I've also attached an image of the same curve drawn in Excel and JForex to show where it's different. It becomes really apparent around the 20th Feb (data point 157 in Excel).

I'm pretty confident that I've just done something dumb and that's why it's showing up differently.

Thanks in advance,

Tommy


Attachments:
rsx jforex.png [23.68 KiB]
Downloaded 332 times
rsx excel.png [26.79 KiB]
Downloaded 324 times
RSXOscillator.java [6.01 KiB]
Downloaded 283 times
RSXDemoStrat.java [2.36 KiB]
Downloaded 278 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.
 
 Post subject: Re: Different results using instrument in JForex client to stand-alone API Post rating: 0   New post Posted: Fri 30 Mar, 2012, 10:51 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
tommy5d wrote:
It becomes really apparent around the 20th Feb (data point 157 in Excel).
Well it is Monday, so this could be due to Weekends filter - for instance, chart uses no filter, but the strategy - Weekends filter. Please go through the following checklist:
https://www.dukascopy.com/wiki/#Indicato ... _checklist
Also consider using OHLC informer to check if the values on chart match the ones of strategy:
https://www.dukascopy.com/wiki/#Add_indicators_on_chart/Include_in_OHLC
You can also plot the indicators on chart and use OHLC in in Standalone:
https://www.dukascopy.com/wiki/#Standalo ... t_controls

If the values still don't match, then please provide a list of candle stick bars for which this is the case.


 
 Post subject: Re: Different results using instrument in JForex client to stand-alone API Post rating: 0   New post Posted: Mon 02 Apr, 2012, 18:14 

User rating: 5
Joined: Thu 29 Mar, 2012, 15:00
Posts: 19
Thanks for the swift reply...

I've been through your instructions and learnt a reasonable amount of new stuff but I'm still unable to get to the bottom of my issue.

I've been through all of the settings and ensured they're the same across both the client and the strategy but all of my results seem to be off to some degree. The overall trend is there but it seems to fluctuate more quickly in my CSV of data than the actual OHLC informer data.

I've attached some code which can either be run standalone or through the client which adds my indicator to a chart and it works correctly but also exports a CSV of the data being manually generated from onBar... you'll be able to see for yourself that they don't match up. I'm sure though I've just messed something up in the onBar call... I'd be extremely grateful if you could tell me what it is.

Thank you again,

Tommy


Attachments:
RSXDemoStrat.zip [6.75 KiB]
Downloaded 284 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.
 
 Post subject: Re: Different results using instrument in JForex client to stand-alone API Post rating: 0   New post Posted: Tue 03 Apr, 2012, 13:45 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
For us the indicator does not draw anything after the back-testing start:
Image


Attachments:
RSXOscillator.png [30.08 KiB]
Downloaded 499 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.
 
 Post subject: Re: Different results using instrument in JForex client to stand-alone API Post rating: 0   New post Posted: Tue 03 Apr, 2012, 16:29 

User rating: 5
Joined: Thu 29 Mar, 2012, 15:00
Posts: 19
Okay, thanks for trying it... My graph also seems to stop at roughly the beginning of the 26th March like yours does when back testing but it's not fair to say that it doesn't draw at all after the back-testing starts. If I do for the Last 3 months then it does all the data up until that date. I'm not sure why this is... the values being generated in my onBar in the CSV carry on all the way up to the current day and when I attach the indicator to the chart I get the indicator drawn all the way to the current day.

Really, I'd be extremely happy if you could just explain to me why the data being generated from onBar and put out to the CSV is different to that drawn on the graph?

The data from the graph is simply coming from the following line:

chart.addIndicator(indicators.getIndicator("RSXOscillator"), new Object[] { 21 });


The way I'm getting the data in the onBar method is using:

Object[] rsxArray1 = this.indicators.calculateIndicator(Instrument.EURUSD, Period.ONE_HOUR, new OfferSide[] { OfferSide.BID }, "RSXOscillator",
                    new IIndicators.AppliedPrice[] { IIndicators.AppliedPrice.CLOSE }, new Object[] { 21 }, Filter.WEEKENDS, 21, bidBar.getTime(), 1);


Is the best way to get indicator data in a strategy to do this in the onBar or is there a way of accessing the indicator data that's already on the chart?

Thank you,

Tommy


 
 Post subject: Re: Different results using instrument in JForex client to stand-alone API Post rating: 0   New post Posted: Thu 05 Apr, 2012, 10:32 

User rating: 5
Joined: Thu 29 Mar, 2012, 15:00
Posts: 19
Sorry to be a nag but please let me know how you get on with this as it's holding me back from pushing my strategy live.

I think it should be relatively easy to see the problem yourselves... simply add the chart in JForex and match the filter, etc. to that from the code below and compare it to the values that are generated from this code in the onBar method.

Object[] rsxArray1 = this.indicators.calculateIndicator(Instrument.EURUSD, Period.ONE_HOUR, new OfferSide[] { OfferSide.BID }, "RSXOscillator",
                    new IIndicators.AppliedPrice[] { IIndicators.AppliedPrice.CLOSE }, new Object[] { 21 }, Filter.WEEKENDS, 21, bidBar.getTime(), 1);


You'll see that although the overall trend is correct for some reason all the individual values are off. It also appears that the values given from the code react a lot quicker to newer price data? I'm sure the problem will simply be how I've called the custom indicator, probably in the last few parameters I've provided, i.e. the numberOfBarsBefore, time, numberOfBarsAfter.

If you can't see what the problem is I'd be incredibly grateful if could you knock me up a simple strategy that uses this custom indicator properly?

Thank you in advance,


 
 Post subject: Re: Different results using instrument in JForex client to stand-alone API Post rating: 0   New post Posted: Thu 05 Apr, 2012, 10:47 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Also when we add the indicator on chart to work with in-progress data (manually, not from strategy), it drew only zero values after the plotting time point (try with ticks or 10 second bars). Thus, you have to check why the indicator does not calculate with in-progress data in first place.


 
 Post subject: Re: Different results using instrument in JForex client to stand-alone API Post rating: 0   New post Posted: Thu 05 Apr, 2012, 11:53 

User rating: 5
Joined: Thu 29 Mar, 2012, 15:00
Posts: 19
Oh yeah, I see your point. I took the indicator from the custom indicators thread on this forum so I assumed it worked okay! I've got the original MQ4 file around somewhere so I'll have a go at recreating it and if I struggle then I'll send you the MQ4.

Thank you.


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com