Dukascopy
 
 
Wiki JStore Search Login

How to solve the calculation of SAR value is not consistent and icon value
 Post subject: How to solve the calculation of SAR value is not consistent and icon value Post rating: 0   New post Posted: Tue 24 Sep, 2013, 14:24 

User rating: 0
Joined: Thu 29 Aug, 2013, 01:01
Posts: 21
Location: ChinaChina
Management.
I use your JForex platform, in use, I added the "Parabolic SAR" system indicators in the chart, add to the chart is XAU/USD, cycle is 1 minutes, the use of filter parameter is "Acceleration=0.0025, Maximum=0.1", can be displayed in the chart, so I want to write a trailing stop is EA, based on the SAR to calculate, found in the process of calculation, each calculation values to the chart value some error, or even in the wave when the error is large, the code and screenshots in the annex, please professionals analysis, it is very important to me, thank you


Attachments:
_03LongMoveSL.java [5.92 KiB]
Downloaded 97 times
_04ShortMoveSL.java [6.56 KiB]
Downloaded 82 times
计算的不同.JPG [191.92 KiB]
Downloaded 140 times
使用的SAR.JPG [89.61 KiB]
Downloaded 148 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: How to solve the calculation of SAR value is not consistent and icon value Post rating: 0   New post Posted: Tue 24 Sep, 2013, 19:54 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Hi,

Replace the code of the indicator call with this:
Object[] result = indicators.calculateIndicator(feedDescriptor, new OfferSide[] {OfferSide.BID}, "SAR", new AppliedPrice[] { AppliedPrice.CLOSE }, new Object[] {stopLossA,stopLossMax}, 0);
double sarValue=((Double)result[0]);

This will give you the latest SAR value.

The one you have used is the SAR value of the previous bar, not the SAR value of the current bar (that is also shown on the right side of the chart).

See https://www.dukascopy.com/wiki/#Indicator_Calculation, for further references, examples about how to calculate indicators.


 

Jump to:  

  © 1998-2024 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