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.

Calculating BBANDS on array
 Post subject: Calculating BBANDS on array Post rating: 0   New post Posted: Mon 24 Nov, 2014, 22:22 

User rating: 0
Joined: Fri 04 Apr, 2014, 16:35
Posts: 50
Location: Monaco, Monte-Carlo
Hi, I have been looking at:
https://www.dukascopy.com/wiki/#Indicator_Calculation/Calculate_indicator_on_array as I want to calculate bollinger bands (including shift) from an array.
I have looked up all of the metadata for BBANDS:
Output 2: Lower Band - DOUBLE
Output 1: Middle Band - DOUBLE
Output 0: Upper Band - DOUBLE
Opt Input 3: MA type - OTHER
Opt Input 2: Nb Dev Dn - OTHER
Opt Input 1: Nb Dev Up - OTHER
Opt Input 0: Time period - OTHER
Input 0: Price - DOUBLE
Bollinger Bands: input count=1, optional input count=4, output count=3

but everything I have tried does not work.

The code i have for it is:
    
double[] dPriceArray = new double[200];
/*
(a method here generates the price array)
/*

double[] UpperBand = new double [dPriceArray .length];
double[] MiddleBand = new double [dPriceArray .length];
double[] LowerBand = new double [dPriceArray .length];
BBandsIndicator = indicators.getIndicator("BBANDS");
BBandsIndicator.setInputParameter(0,dPriceArray );//price array
BBandsIndicator.setOptInputParameter(0,21);//time period
BBandsIndicator.setOptInputParameter(1,2.0);//#stdevs up
BBandsIndicator.setOptInputParameter(2,2.0);//#stdevs down
BBandsIndicator.setOptInputParameter(3, "WMA");//MA type
BBandsIndicator.setOutputParameter(0,UpperBand);
BBandsIndicator.setOutputParameter(1,MiddleBand);
BBandsIndicator.setOutputParameter(2,LowerBand);


for my array, does the most recent price need to be at dPriceArray[0] or dPriceArray[dPriceArray .length-1]?

Does anyone have a working example they can share or any advice?
Thanks
J


 
 Post subject: Re: Calculating BBANDS on array Post rating: 0   New post Posted: Tue 25 Nov, 2014, 15:44 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please see the attached strategy.
You can also find examples on each indicator here: https://www.dukascopy.com/wiki/#Indicator_catalog/Bollinger_Bands


Attachments:
IndOnArray.java [2.78 KiB]
Downloaded 58 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.
 

Jump to:  

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