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.

Anyone know how to call ATR from IIndicatorsProvider?
 Post subject: Anyone know how to call ATR from IIndicatorsProvider? Post rating: 0   New post Posted: Sat 10 Mar, 2012, 13:54 
User avatar

User rating: 8
Joined: Tue 25 Oct, 2011, 23:02
Posts: 74
Location: Australia, Melbourne
Average True Range, how do you call it from within a custom indicator?

IIndicatorsProvider indicatorsProvider = context.getIndicatorsProvider();
ATR = indicatorsProvider.getIndicator("ATR");


seems to work but actually doesn't return anything.

Tried "atr", "Average True Range", and "ATR".
can't find anything in the documentation or knowledge base.


 
 Post subject: Re: Anyone know how to call ATR from IIndicatorsProvider? Post rating: 0   New post Posted: Sat 10 Mar, 2012, 14:44 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi...

I'm a noob in JForex API but maybe something like this:

double [] atr1 = indicators.atr(instrument, selectedPeriod , OfferSide.BID, int timePeriod, indicatorFilter, long from, long to);

See javadoc for more details

Best regards

Trade well and good luck

JL


 
 Post subject: Re: Anyone know how to call ATR from IIndicatorsProvider? Post rating: 1   New post Posted: Sat 10 Mar, 2012, 23:58 
User avatar

User rating: 8
Joined: Tue 25 Oct, 2011, 23:02
Posts: 74
Location: Australia, Melbourne
Thanks JL.

That's fine if you want to call ATR from within the IStrategy framework, but I'm interested in using ATR as a calculation step in a custom indicator I'm writing. Ideally in this case you don't want to use IHistory or a known set of input bars.

I want to get ATR as an IIndicator and calculate outputs values from inputs and then use them for for further calculations. I have a suspicion that the ATR is not actually called "ATR" so when I call getIndicator(String S), the API can't match S to the built in ATR indicator. There is no documentation on how to call it from the IIndicators framework.

f451


 
 Post subject: Re: Anyone know how to call ATR from IIndicatorsProvider? Post rating: 0   New post Posted: Sun 11 Mar, 2012, 01:56 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi:

Well, at least you can develo your own ATR, seems not hard to develop:

True Range = greater of (H-L, |H-(C-1)|, |L-(C-1)|)

ATR = ((ATR-1) * (interval -1) + TR) / interval

H = High
L = Low
(C-1) = previous close
(ATR-1) = previous ATR

As we need a beginning, the first TR value is H-L
The values of ATR until it reach interval is the average of TR.

I hope that helps if you can't find any solution in API

Best regards

Trade well and good luck

JL


 
 Post subject: Re: Anyone know how to call ATR from IIndicatorsProvider? Post rating: 0   New post Posted: Mon 12 Mar, 2012, 12:11 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
https://www.dukascopy.com/wiki/#Indicator_that_uses_the_output_of_another_indicator
Before making the indicator call, you can find out the necessary indicator metadata (inputs, optional inputs and outputs) in the following way (this can be done either from a strategy or an indicator):
https://www.dukascopy.com/wiki/#Indicator_metadata/Retrieve_indicator_metadata


 

Jump to:  

  © 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