|
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.
Using IHistory in indicator... |
Tyraslin
|
Post subject: Using IHistory in indicator... |
Post rating: 0
|
Posted: Wed 04 Apr, 2012, 15:37
|
|
User rating: 4
Joined: Wed 21 Dec, 2011, 10:21 Posts: 30 Location: France, Sallanches
|
Hello, First of all, i'm a beginner  Is it possible to use the following code, and if yes, how i must use it ? ... import com.dukascopy.api.feed.*;
public class MyForexIndex implements IIndicator { ... private IHistory history; private IBar myBar;
... public void onStart(IIndicatorContext context) { IHistory history=context.getHistory(); myBar=history.getBar(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.ASK, 5); ...
When i try to compile it, i have an unhandled exception type JFException... Did i'm not using this function as it musr be used ? By advance, thanks.
|
|
|
|
 |
tommy5d
|
Post subject: Re: Using IHistory in indicator... |
Post rating: 1
|
Posted: Wed 04 Apr, 2012, 17:07
|
|
User rating: 5
Joined: Thu 29 Mar, 2012, 15:00 Posts: 19
|
All of the methods in IStrategy (onBar, onStart, onTick, etc.) can throw JFException. Therefore you need to change your method to: public void onStart(IIndicatorContext context) throws JFException { IHistory history=context.getHistory(); myBar=history.getBar(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.ASK, 5); }
|
|
|
|
 |
Tyraslin
|
Post subject: Re: Using IHistory in indicator... |
Post rating: 0
|
Posted: Thu 05 Apr, 2012, 02:55
|
|
User rating: 4
Joined: Wed 21 Dec, 2011, 10:21 Posts: 30 Location: France, Sallanches
|
Thanks tommy5d. However, when i try to compile it, an error occurs: Quote: Exception JFException is not compatible with throws clause in IIndicator.onStart(IIndicatorContext) Ant idea ? Thanks
|
|
|
|
 |
API Support
|
Post subject: Re: Using IHistory in indicator... |
Post rating: 0
|
Posted: Thu 05 Apr, 2012, 07:19
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
What are you trying to do? Are you trying to make a strategy or an indicator?
|
|
|
|
 |
Tyraslin
|
Post subject: Re: Using IHistory in indicator... |
Post rating: 0
|
Posted: Thu 05 Apr, 2012, 12:34
|
|
User rating: 4
Joined: Wed 21 Dec, 2011, 10:21 Posts: 30 Location: France, Sallanches
|
I'm trying to make an indicator.
|
|
|
|
 |
API Support
|
Post subject: Re: Using IHistory in indicator... |
Post rating: 0
|
Posted: Thu 05 Apr, 2012, 13:04
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
You need to handle the JFException, i.e. surround it with a try-catch block, as it is done in the following indicator (see lines 80 and 91): viewtopic.php?f=6&t=42796
|
|
|
|
 |
Tyraslin
|
Post subject: Re: Using IHistory in indicator... |
Post rating: 0
|
Posted: Thu 05 Apr, 2012, 16:32
|
|
User rating: 4
Joined: Wed 21 Dec, 2011, 10:21 Posts: 30 Location: France, Sallanches
|
Thanks for you help ! Everything is working now !
Thanks again !
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|