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.

Using non standard time frame for indicator
 Post subject: Using non standard time frame for indicator Post rating: 0   New post Posted: Thu 18 Jun, 2015, 16:23 

User rating: 0
Joined: Thu 12 Dec, 2013, 09:24
Posts: 21
Location: Ukraine, Kyiv
I have the following challenge. I need to automate strategy with non standard time frame ( 3 min, 2H, 8H ). For strategy to work properly I need to have access to 3min ema indicator.
In order to achieve it in my class declaration I wrote the following:

import java.util.*;

import com.dukascopy.api.*;
import com.dukascopy.api.feed.*;
import com.dukascopy.api.feed.util.*;
import com.dukascopy.api.IIndicators.AppliedPrice;

public class NeuralNetworkSniper implements IStrategy {
public Period period3Min = Period.createCustomPeriod(Unit.Minute, 3);

/*here goes onStart, onAccount, etc. functions*/

private double eMaValue(long period, long shift)throws JFException
{
double ema = indicators.ema(Instrument.EURUSD, period3Min , OfferSide.ASK, AppliedPrice.CLOSE, 5, shift);
return ema;
}
}

but when I try to compile I receive following error message:

2015-06-18 18:21:03 ----------
2015-06-18 18:21:03 The method ema(Instrument, Period, OfferSide, IIndicators.AppliedPrice, int, int) in the type IIndicators is not applicable for the arguments (Instrument, Period, OfferSide, IIndicators.AppliedPrice, int, long)
2015-06-18 18:21:03 ^^^
2015-06-18 18:21:03 double ema = indicators.ema(Instrument.EURUSD, period3Min , OfferSide.ASK, AppliedPrice.CLOSE, 5, shift);
2015-06-18 18:21:03 1. ERROR in C:\Users\yzaletskyy\AppData\Local\JForex\yzaletskyy\jfxide\tmp\compile\NeuralNetworkSniper.java (at line 123)
2015-06-18 18:21:03 ----------

does anybody knows how can I get needed information?


 
 Post subject: Re: Usint non standard time frame for indicator Post rating: 0   New post Posted: Mon 22 Jun, 2015, 10:09 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
You need universal price feed to calculate indicator values on custom periods.
https://www.dukascopy.com/wiki/#Indicat ... price_feed


 
 Post subject: Re: Using non standard time frame for indicator Post rating: 0   New post Posted: Tue 23 Jun, 2015, 20:40 

User rating: 0
Joined: Thu 12 Dec, 2013, 09:24
Posts: 21
Location: Ukraine, Kyiv
Here is how I solved it:

///Returns ema for period, with shift
private double eMaValue(int period, int shift)throws JFException
{
double ema = indicators.ema(currentInstrument, period3Min , OfferSide.ASK, AppliedPrice.CLOSE, period, shift);
return ema;
}


 

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