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.

Strategies and Feeds
 Post subject: Strategies and Feeds Post rating: 0   New post Posted: Mon 17 Dec, 2012, 10:05 

User rating: 0
Joined: Mon 03 Dec, 2012, 09:55
Posts: 30
Hi ... I am pretty new to JFOREX and just finding my way around. I am writing a REnko based strategy and I see two different ways to do it.

1) Subscribe to a feed and workin within thr OnFeedData function ... or I can can the strategy to implement IRenkoBarFeedListener and simply add an OnBar function.

Could you outline the benefits/differences in the two apprioaches ...

Thanks

Paul


 
 Post subject: Re: Strategies and Feeds Post rating: 0   New post Posted: Mon 17 Dec, 2012, 13:19 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The endorsed approach is to use IFeedListerer.onFeedData, since it allows you to define the IFeedDescriptor only once and thereafter use it to fetch historical data (IHistory.getFeedData) and indicators (IIndicators.calculateIndicator) without having to repeat the feed parameters. This also means that you can, for example, switch between 5-pip renkos and 1-min bars simply by changing the IFeedDescriptor initialization. If you would use IRenkoBarFeedListener you would need to not only redefine the IFeedDescriptor, but also change the listener and history call methods. See more here:
https://www.dukascopy.com/wiki/#Chart_feeds


 
 Post subject: Re: Strategies and Feeds Post rating: 0   New post Posted: Mon 17 Dec, 2012, 14:23 

User rating: 0
Joined: Mon 03 Dec, 2012, 09:55
Posts: 30
Hi thanks

The only problem with that is that the examples you give dont actrually compile ! you get "Cannot refer to a non-final variable context inside an inner class defined in a different ..." and I presume if you try an access orders etc in the OnFeedData you will get similiar errors?


 
 Post subject: Re: Strategies and Feeds Post rating: 0   New post Posted: Mon 17 Dec, 2012, 14:45 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Which example do you refer to?


 
 Post subject: Re: Strategies and Feeds Post rating: 0   New post Posted: Mon 17 Dec, 2012, 14:50 

User rating: 0
Joined: Mon 03 Dec, 2012, 09:55
Posts: 30
Hi

We if u create a strategy shell and add


@Override
public void onStart(final IContext context) throws JFException {
IFeedDescriptor rangeBarFeedDescriptor = new RangeBarFeedDescriptor(Instrument.EURUSD, PriceRange.TWO_PIPS, OfferSide.ASK);
context.subscribeToFeed(rangeBarFeedDescriptor, new IFeedListener() {
@Override
public void onFeedData(IFeedDescriptor feedDescriptor, ITimedData feedData) {
context.getConsole().getOut().println("completed: " + feedData + " of feed: " + feedDescriptor);
}
});
}

you get a compliation error on the line
context.getConsole().getOut().println("completed: " + feedData + " of feed: " + feedDescriptor);


Thanks


 
 Post subject: Re: Strategies and Feeds Post rating: 0   New post Posted: Mon 17 Dec, 2012, 15:06 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
please provide full example strategy and the source where you downloaded it from.


 

Jump to:  

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