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.

Candle data to array
 Post subject: Candle data to array Post rating: 0   New post Posted: Fri 13 Sep, 2013, 05:41 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
I am trying to code for the following:-

1) get the last six hours bar data OHLC and Volume
2) print values to console, and
3) save this data to an array

my code (with errors) is as follows......................

________________________________________________
long prevBarTime = myHistory.getPreviousBarStart(myPeriod, myHistory.getLastTick(myInstrument), getTime());
List<IBar> bars = myHistory.getBars(myInstrument, myPeriod, OfferSide.BID, Filter.WEEKENDS, 6, prevBarTime, 0);

for(Ibar Bar:bars){
myConsole.getOut()println(bar.getTime() + "," + bar.getOpen()..........+ bar.getVolume());
}

public double [] [] IBarstoArray(List inputBars)

double [] [] ohlcvArray = new double[5] [inputBars.size()];
for (int=0;i<inputBars.size();i++){
ohlcvArray[0][i] = inputBars.get(i).getOpen();
.............................................................
ohlcvArray[4][i] = inputBars.get(i).getVolume();
}
return ohlcvArray;
____________________________________________________
doesn't like Filter.WEEKENDS
doesn't like .getOpen(), getVolume() etc.

Where am I going wrong?

Thanks

Bob M


 
 Post subject: Re: Coding help please Post rating: 0   New post Posted: Fri 13 Sep, 2013, 08:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We can't conclude anything meaningful without:
  1. a full example strategy which demonstrates the problem;
  2. description of what the strategy does wrong;
  3. description of what is the expected behavior.


 
 Post subject: Re: Candle data to array Post rating: 0   New post Posted: Sun 15 Sep, 2013, 02:57 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
Thank you Support

Please could you show me example code to do the following under OnBar method

1) every six hours - read in last six completed bar data for instrument1
2) create an array which holds this data
1st element - Open value
2nd element - High value
3rd element - Low value
4th element - Close value
5th element - BID.Volume
3) print out each of the six hourly array elements (with OHLCV values) to the console

Many thanks

Bob M


 
 Post subject: Re: Candle data to array Post rating: 0   New post Posted: Mon 16 Sep, 2013, 08:22 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
us_copiosus wrote:
1) every six hours - read in last six completed bar data for instrument1
Subscribe to a six hour feed:
https://www.dukascopy.com/wiki/#Chart_feeds/Subscribe_to_a_feed
and then get bars by candle interval:
https://www.dukascopy.com/wiki/#History_bars/Bars_by_candle_interval
us_copiosus wrote:
2) create an array which holds this data
1st element - Open value
2nd element - High value
3rd element - Low value
4th element - Close value
5th element - BID.Volume
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
us_copiosus wrote:
3) print out each of the six hourly array elements (with OHLCV values) to the console
For printing values see:
https://www.dukascopy.com/wiki/#IConsole
In particular for printing arrays see:
https://www.dukascopy.com/wiki/#IConsole/Logging_values
Alternatively you may also use Arrays.toString.


 
 Post subject: Re: Candle data to array Post rating: 0   New post Posted: Tue 17 Sep, 2013, 04:54 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
Hi Support and others :)

Am having trouble understanding "subscribe to a six hour feed"

Which Data_Type am I looking for:- Tick_Bar?

As soon as I add ", IFeedListener" to the public class I get IFeedListener cannot be resolved to a type error message

Bob M

p.s. an example of the code would assist


 
 Post subject: Re: Candle data to array Post rating: 0   New post Posted: Tue 17 Sep, 2013, 07:14 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
us_copiosus wrote:
Am having trouble understanding "subscribe to a six hour feed"

Which Data_Type am I looking for:- Tick_Bar?
You are looking for:
IFeedDescriptor feedDescriptor = new TimePeriodAggregationFeedDescriptor(Instrument.EURUSD, Period.createCustomPeriod(Unit.Hour, 6),
            OfferSide.BID, Filter.NO_FILTER);

us_copiosus wrote:
As soon as I add ", IFeedListener" to the public class I get IFeedListener cannot be resolved to a type error message

You need to add necessary imports. Consider using an IDE for your strategy development, e.g., Eclipse or NetBeans - they provide automatic-fix assistance for such cases.


 
 Post subject: Re: Candle data to array Post rating: 0   New post Posted: Tue 17 Sep, 2013, 08:05 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
and the necessary imports are..............??

Bob M


 
 Post subject: Re: Candle data to array Post rating: 0   New post Posted: Tue 17 Sep, 2013, 08:14 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
import com.dukascopy.api.feed.*;
import com.dukascopy.api.feed.util.*;
But we strongly advise you using an IDE to solve this as well as other compile-time errors for you automatically.


 

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