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.

Can't add indicator to my strategy PercentBollingerBands
 Post subject: Can't add indicator to my strategy PercentBollingerBands Post rating: 0   New post Posted: Thu 14 Jul, 2016, 15:13 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Hi there!

Started use IDE for strategy create.

I want to add a PercentBollingerBands indicator to use in my strategy code but can't find it in the Indicators LIST , Only a BBands indicator.
Image
Please advice


 
 Post subject: Re: Can't add indicator to my strategy PercentBollingerBands Post rating: 0   New post Posted: Mon 25 Jul, 2016, 08:23 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Here is code that calculates PERSBBANDS.

IFeedDescriptor fd = new TimePeriodAggregationFeedDescriptor(Instrument.EURUSD, Period.TEN_MINS, OfferSide.BID);
        Object[] indicatorResult = indicators.calculateIndicator(fd, new OfferSide[] {OfferSide.BID}, "PERSBBANDS", new  IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {20, 2.0}, 1);
        console.getOut().println(indicatorResult[0]);


 
 Post subject: Re: Can't add indicator to my strategy PercentBollingerBands Post rating: 0   New post Posted: Mon 25 Jul, 2016, 13:29 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Thanks alot!


 
 Post subject: Re: Can't add indicator to my strategy PercentBollingerBands Post rating: 0   New post Posted: Tue 26 Jul, 2016, 12:13 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Hello again.

I added your code to my strategy and tried to adjust filter in it
public  IFeedDescriptor fd = new TimePeriodAggregationFeedDescriptor(instr, per, OfferSide.BID, Filter.ALL_FLATS);
Object[] indicatorResult = indicators.calculateIndicator(fd, new OfferSide[] {OfferSide.BID}, "PERSBBANDS", new  IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {40, 1.8}, 1);
 console.getOut().println(indicatorResult[0]);

But it takes into consideration weekend prices and shows me a bad values of indicator. Image

Any suggestions?


 
 Post subject: Re: Can't add indicator to my strategy PercentBollingerBands Post rating: 1   New post Posted: Tue 16 Aug, 2016, 09:08 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello.

This universal function for indicator calculation by shift doesn't use filter set in feedDescriptor and no filtration is applied during calculation.
See JavaDoc for IIndicators.calculateIndicator(IFeedDescriptor feedDescriptor, OfferSide[] offerSides, String functionName, AppliedPrice[] inputTypes, Object[] optParams, int shift)
But you can use another function - for indicator calculation by candle interval:

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if (!instrument.equals(Instrument.EURUSD) || !period.equals(Period.ONE_HOUR)) {
return;
}

IFeedDescriptor fd = new TimePeriodAggregationFeedDescriptor(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.BID, Filter.ALL_FLATS);
Object[] indicatorResult = indicators.calculateIndicator(fd, new OfferSide[] {OfferSide.BID}, "PERSBBANDS",
new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {40, 1.8}, 1, bidBar.getTime(), 0);
console.getOut().println(((double[]) indicatorResult[0])[0]);
}

Kind regards, Support Team.


 
 Post subject: Re: Can't add indicator to my strategy PercentBollingerBands Post rating: 0   New post Posted: Mon 05 Sep, 2016, 12:30 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Thanks for solution and best regards! :)


 

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