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.

problem in stochastic indicator
 Post subject: problem in stochastic indicator Post rating: 0   New post Posted: Tue 19 Feb, 2013, 13:02 

User rating: 0
Joined: Tue 19 Feb, 2013, 12:48
Posts: 2
Location: Portugal, Lisboa
Hi,

according to javadoc the stoch method should return shift+1 values in the returned array

double[] stoch(Instrument instrument,
               Period period,
               OfferSide side,
               int fastKPeriod,
               int slowKPeriod,
               IIndicators.MaType slowKMaType,
               int slowDPeriod,
               IIndicators.MaType slowDMaType,
               int shift)
               throws JFException

using this line of code

            double[] stochastic = indicators.stoch(instrument, fixedPeriod, side, fastKPeriod, slowKPeriod , slowKMaType,
                    slowDPeriod, slowDMaType,  5);

the double array is getting only 2 positions created. a reference to stochastic[2] or stochastic[3] is raising an exception.

tested on EUR/USD, 15 mins with
    private OfferSide side = OfferSide.BID;
    private int fastKPeriod = 5;
    private MaType slowDMaType =  MaType.SMA;
    private int slowKPeriod = 3;
    private MaType slowKMaType =  MaType.SMA;
    private int slowDPeriod = 3;

please check or correct me if i am wrong.

many thanks
camapeta


 
 Post subject: Re: problem in stochastic indicator Post rating: 0   New post Posted: Tue 19 Feb, 2013, 13:50 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
If you calculate the values by shift, you get values for a single candle only - in this case each array element stands for an output - and as you see stoch has two outputs.
If you wish to retrieve a value array for each of the outputs over a candle interval, use the following method:
https://www.dukascopy.com/wiki/#Indicator_Calculation/Calculate_indicator_by_candle_interval


 

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