Dukascopy
 
 
Wiki JStore Search Login

rsi equals 0 or 100
 Post subject: rsi equals 0 or 100 Post rating: 0   New post Posted: Sun 25 Aug, 2013, 16:28 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
in backtest mode, I can't figure out why the rsi indicator always return 0 or 100

      double rsi = indicators.rsi(instrument, Period.FIFTEEN_MINS, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 1, 0);

edit: work by changing timePeriod

Could you put an enum like Period for it in the future versions to avoid confusions?


 
 Post subject: Re: rsi equals 0 or 100 Post rating: 0   New post Posted: Mon 26 Aug, 2013, 12:15 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
lil wrote:
Could you put an enum like Period for it in the future versions to avoid confusions?

public static final Period FIFTEEN_MINS

What is this if not an enum?


 
 Post subject: Re: rsi equals 0 or 100 Post rating: 0   New post Posted: Mon 26 Aug, 2013, 13:58 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
tcsabina wrote:
lil wrote:
Could you put an enum like Period for it in the future versions to avoid confusions?

public static final Period FIFTEEN_MINS

What is this if not an enum?


talking about the 5th argument: int timePeriod,
this one looks mysterious to me


 
 Post subject: Re: rsi equals 0 or 100 Post rating: 0   New post Posted: Mon 26 Aug, 2013, 16:07 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi lil...

That parameter is the iinterval of periods to take in consideration... Take a example "MA"... you can get the values of "MA" related with Period.1HOUR, but take in consideration the average of 21 "periods" or "bars"... This 21 is your 5º parameter. This way can't be a enum as it will be needed a enum item for each int and that not makes sense.

I hope this helps

Trade well

JL


 
 Post subject: Re: rsi equals 0 or 100 Post rating: 1   New post Posted: Mon 26 Aug, 2013, 23:06 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
lil wrote:
talking about the 5th argument: int timePeriod

sorry monsieur :)
lil wrote:
this one looks mysterious to me

To calculate RSI you need to define a period (like 15 min), and a lookback (like 14, which is the default). This means that you will use the last 14 15M bars to calculate the value of RSI. The javadoc uses period for the chart's period, and timePeriod for the lookback, which could be confusing, as both contains the word, period. Now, which one does what? I think it would be better if we call them period and lookback, but this is just a personal opinion.
To have a grasp on these parameter, just put RSI on a chart on the platform:
When you put RSI indicator on the chart, the chart's period (like 15M or 4H) will be the period parameter of the indicator, and the lookback is a changeable indicator parameter (with 14 as default). If you change the chart's period to, let's say, to 4H, and leave Time period (which I called lookback) on 14, then for RSI calculation you will use the last 14 4H bars.

When you use the API, the 5th parameter is the lookback parameter. And as JLongo pointed out, it cannot be an enum, as you can use whatever number (integer of course) you want.

More on calculating RSI can be found (for example) here.

I hope this helps.


 
 Post subject: Re: rsi equals 0 or 100 Post rating: 0   New post Posted: Tue 27 Aug, 2013, 09:17 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
thanks for explanations, for someone not familiar with this.

I was also confused by the use of timePeriod in Pivot lines https://www.dukascopy.com/client/javadoc/com/dukascopy/api/IIndicators.html#pivot(com.dukascopy.api.Instrument,%20com.dukascopy.api.Period,%20com.dukascopy.api.OfferSide,%20int,%20com.dukascopy.api.Filter,%20int,%20long,%20int) where it's bounded between 0 and 9, but I guess there are specific cases and values for all indicators


 
The Best Answer  Post subject: Re: rsi equals 0 or 100 Post rating: 0   New post Posted: Tue 27 Aug, 2013, 12:01 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Oh, I can see it now. It is indeed confusing.
What you can try in the future is to drop the actual indicator on a chart. There you can see what parameters does what. The first 3 parameters are almost always as follows: instrument, period, offerside. These are not selectable parameters for an indicator on chart, as they are coming from the chart itself.

But I guess you are now able to figure it out...


 

Jump to:  

cron
  © 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