|
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 |
Illya
|
Post subject: Can't add indicator to my strategy PercentBollingerBands |
Post rating: 0
|
Posted: Thu 14 Jul, 2016, 15:13
|
|
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.  Please advice
|
|
|
|
 |
API Support
|
Post subject: Re: Can't add indicator to my strategy PercentBollingerBands |
Post rating: 0
|
Posted: Mon 25 Jul, 2016, 08:23
|
|
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]);
|
|
|
|
 |
Illya
|
Post subject: Re: Can't add indicator to my strategy PercentBollingerBands |
Post rating: 0
|
Posted: Mon 25 Jul, 2016, 13:29
|
|
User rating: 6
Joined: Wed 05 Mar, 2014, 12:00 Posts: 116 Location: Ukraine, Odessa
|
|
|
|
 |
Illya
|
Post subject: Re: Can't add indicator to my strategy PercentBollingerBands |
Post rating: 0
|
Posted: Tue 26 Jul, 2016, 12:13
|
|
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.  Any suggestions?
|
|
|
|
 |
API Support
|
Post subject: Re: Can't add indicator to my strategy PercentBollingerBands |
Post rating: 1
|
Posted: Tue 16 Aug, 2016, 09:08
|
|
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.
|
|
|
|
 |
Illya
|
Post subject: Re: Can't add indicator to my strategy PercentBollingerBands |
Post rating: 0
|
Posted: Mon 05 Sep, 2016, 12:30
|
|
User rating: 6
Joined: Wed 05 Mar, 2014, 12:00 Posts: 116 Location: Ukraine, Odessa
|
Thanks for solution and best regards! 
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|