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.

How to receive last value of indicator on custom period?
 Post subject: How to receive last value of indicator on custom period? Post rating: 0   New post Posted: Tue 27 Aug, 2013, 09:20 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
I try receive last (0) value of indicarotr (EMA) using custom period 3 min.

if I try use it in this way:

indicators.ema(instrumentThis, Period.createCustomPeriod(Unit.Minute, 3), OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 20, 0);


I receive NaN. It is bug? or I can do this in other way?

Below simple strategy where I try to use it.

Please help


Attachments:
CustomPeriodInIndicatorTest.java [1.3 KiB]
Downloaded 363 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: How to receive last value of indicator on custom period? Post rating: 0   New post Posted: Tue 27 Aug, 2013, 11:54 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Download and run the example given here:
https://www.dukascopy.com/wiki/#Indicator_Calculation/Universal_price_feed


 
 Post subject: Re: How to receive last value of indicator on custom period? Post rating: 0   New post Posted: Tue 27 Aug, 2013, 16:06 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
It also does not work. For standard periods all is ok. Problem is with custom periods.

I try alseo this way:

IFeedDescriptor feedDescriptor = new TimePeriodAggregationFeedDescriptor(instrumentThis, Period.createCustomPeriod(Unit.Minute, 3), OfferSide.BID);
            Object[] emaFeed = indicators.calculateIndicator(feedDescriptor, new OfferSide[] { OfferSide.BID }, "EMA",
            new IIndicators.AppliedPrice[] { IIndicators.AppliedPrice.CLOSE }, new Object[] { 20 }, 0);
            double em = (Double) emaFeed[0];


And it also return NaN.

Please help me.


 
 Post subject: Re: How to receive last value of indicator on custom period? Post rating: 0   New post Posted: Tue 27 Aug, 2013, 16:10 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Mind that you need to subscribe to the feed, as given in the example.


 
 Post subject: Re: How to receive last value of indicator on custom period? Post rating: 0   New post Posted: Tue 27 Aug, 2013, 21:10 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
It works. Thanks


 

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