|
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 |
us_copiosus
|
Post subject: Candle data to array |
Post rating: 0
|
Posted: Fri 13 Sep, 2013, 05:41
|
|
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
|
|
|
|
 |
API Support
|
Post subject: Re: Coding help please |
Post rating: 0
|
Posted: Fri 13 Sep, 2013, 08:04
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
We can't conclude anything meaningful without: - a full example strategy which demonstrates the problem;
- description of what the strategy does wrong;
- description of what is the expected behavior.
|
|
|
|
 |
us_copiosus
|
Post subject: Re: Candle data to array |
Post rating: 0
|
Posted: Sun 15 Sep, 2013, 02:57
|
|
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
|
|
|
|
 |
API Support
|
Post subject: Re: Candle data to array |
Post rating: 0
|
Posted: Mon 16 Sep, 2013, 08:22
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
us_copiosus
|
Post subject: Re: Candle data to array |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 04:54
|
|
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
|
|
|
|
 |
API Support
|
Post subject: Re: Candle data to array |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 07:14
|
|
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.
|
|
|
|
 |
us_copiosus
|
Post subject: Re: Candle data to array |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 08:05
|
|
User rating: 2
Joined: Fri 02 Mar, 2012, 22:08 Posts: 200 Location: New Zealand, Dunedin
|
and the necessary imports are..............??
Bob M
|
|
|
|
 |
API Support
|
Post subject: Re: Candle data to array |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 08:14
|
|
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.
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|