|
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.
| Could you tell me how to use the return value of indicators.rsi method |
|
leevo
|
| Post subject: Could you tell me how to use the return value of indicators.rsi method |
Post rating: 0
|
Posted: Mon 26 Jan, 2015, 20:02
|
|
User rating: 0
Joined: Sat 17 Jan, 2015, 18:46 Posts: 34 Location: China, Shanghai
|
|
double[] rsi14askResults = indicators.rsi(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.ASK, AppliedPrice.CLOSE, 14, Filter.NO_FILTER, 30, time, 0);
the return values are not closed to right rsi values, which I can find in jforex platform.
another important question is I see the rsi values in jforex platform maybe a half of the ask price add bid price, but in the indicators.rsi method, I must give one offerside, can I set the offerside in jforex platform? or get the same a half of the ask price add bid price from the strategy.
|
|
|
|
|
 |
|
API Support
|
| Post subject: Re: Could you tell me how to use the return value of indicators.rsi method |
Post rating: 0
|
Posted: Wed 28 Jan, 2015, 09:37
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
RSI indicator is recursive and requires more values to be calculated. Only then will the outputs exactly match chart values. public void onStart(IContext context) throws JFException { this.console = context.getConsole(); this.history = context.getHistory(); this.indicators = context.getIndicators();
Instrument instrument = Instrument.EURUSD; Period period = Period.ONE_HOUR; long time = history.getLastTick(instrument).getTime(); time = history.getBarStart(period, time); int len = 4000; double[] rsiOut = indicators.rsi(instrument, Period.ONE_HOUR, OfferSide.ASK, AppliedPrice.CLOSE, 14, Filter.NO_FILTER, len, time, 0); console.getOut().println(arrToString(rsiOut, len - 3, instrument)); }
private String arrToString(double[] arr, int from, Instrument instrument) { StringBuffer sb = new StringBuffer(); for (int r = from; r < arr.length; r++) { sb.append(String.format("[%s] %." + (instrument.getPipScale() + 1) + "f; ", r, arr[r])); } return sb.toString(); }
|
|
|
|
|
 |
|
leevo
|
| Post subject: Re: Could you tell me how to use the return value of indicators.rsi method |
Post rating: 0
|
Posted: Wed 28 Jan, 2015, 14:23
|
|
User rating: 0
Joined: Sat 17 Jan, 2015, 18:46 Posts: 34 Location: China, Shanghai
|
Oh. it's too bad, so you should rewrite the method for rsi with using parameter 'shift', it can not get right so far. API Support wrote: RSI indicator is recursive and requires more values to be calculated. Only then will the outputs exactly match chart values. public void onStart(IContext context) throws JFException { this.console = context.getConsole(); this.history = context.getHistory(); this.indicators = context.getIndicators();
Instrument instrument = Instrument.EURUSD; Period period = Period.ONE_HOUR; long time = history.getLastTick(instrument).getTime(); time = history.getBarStart(period, time); int len = 4000; double[] rsiOut = indicators.rsi(instrument, Period.ONE_HOUR, OfferSide.ASK, AppliedPrice.CLOSE, 14, Filter.NO_FILTER, len, time, 0); console.getOut().println(arrToString(rsiOut, len - 3, instrument)); }
private String arrToString(double[] arr, int from, Instrument instrument) { StringBuffer sb = new StringBuffer(); for (int r = from; r < arr.length; r++) { sb.append(String.format("[%s] %." + (instrument.getPipScale() + 1) + "f; ", r, arr[r])); } return sb.toString(); }
|
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|