Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Annotation @Library using by indicators
 Post subject: Annotation @Library using by indicators Post rating: 0   New post Posted: Sun 09 Feb, 2014, 19:54 

User rating: 0
Joined: Tue 18 Jun, 2013, 21:55
Posts: 14
Location: Slovakia, Nitra
Greetings,

I am trying to solve the problem with including external classes into indicators but whithout positive results... I try to use annotation @Library with the indicators, but it seems it doesn't work (except strategies). I found this: https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=48199&p=67364&hilit=import+class+indicators#p67364 and API Support claims it is possible.

I need it because of my extended class for indicators.

Best regards
bojno


 
 Post subject: Re: Annotation @Library using by indicators Post rating: 0   New post Posted: Mon 10 Feb, 2014, 08:46 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
What errors do you get?


 
 Post subject: Re: Annotation @Library using by indicators Post rating: 0   New post Posted: Mon 10 Feb, 2014, 09:17 

User rating: 0
Joined: Tue 18 Jun, 2013, 21:55
Posts: 14
Location: Slovakia, Nitra
Greetings,

Firstly, I am not sure why this thread was moved into Automated Trading - Knowledge Base, because I don't work on strategy, but on indicator. As I said, annotation @Library works well with stategies but when I try to use it with API of indicators it doesn't work...

package jforex;

import com.dukascopy.api.indicators.*;

import com.dukascopy.api.RequiresFullAccess;
import com.dukascopy.api.Library;




import x.Indicator; // The import x cannot be resolved     (There is no error in stragy...)




@RequiresFullAccess
@Library("C:\\Users\\Dávid\\Documents\\JForex\\Indicators\\myLib.jar")
public class ABCIndicator implements IIndicator {
    private IndicatorInfo indicatorInfo;
    private InputParameterInfo[] inputParameterInfos;
    private OptInputParameterInfo[] optInputParameterInfos;
    private OutputParameterInfo[] outputParameterInfos;
    private double[][] inputs = new double[1][];
    private int timePeriod = 2;
    private double[][] outputs = new double[1][];
   
    public void onStart(IIndicatorContext context) {
        indicatorInfo = new IndicatorInfo("EXAMPIND", "Sums previous values", "My indicators",
                false, false, false, 1, 1, 1);
        inputParameterInfos = new InputParameterInfo[] {new InputParameterInfo("Input data", InputParameterInfo.Type.DOUBLE)};
        optInputParameterInfos = new OptInputParameterInfo[] {new OptInputParameterInfo("Time period", OptInputParameterInfo.Type.OTHER,
                new IntegerRangeDescription(2, 2, 100, 1))};
        outputParameterInfos = new OutputParameterInfo[] {new OutputParameterInfo("out", OutputParameterInfo.Type.DOUBLE,
                OutputParameterInfo.DrawingStyle.LINE)};
    }

    public IndicatorResult calculate(int startIndex, int endIndex) {
        //calculating startIndex taking into account lookback value
        if (startIndex - getLookback() < 0) {
            startIndex -= startIndex - getLookback();
        }
        int i, j;
        for (i = startIndex, j = 0; i <= endIndex; i++, j++) {
            double value = 0;
            for (int k = timePeriod; k > 0; k--) {
                value += inputs[0][i - k];
            }
            outputs[0][j] = value;
        }
        return new IndicatorResult(startIndex, j);
    }

    public IndicatorInfo getIndicatorInfo() {
        return indicatorInfo;
    }

    public InputParameterInfo getInputParameterInfo(int index) {
        if (index <= inputParameterInfos.length) {
            return inputParameterInfos[index];
        }
        return null;
    }

    public int getLookback() {
        return timePeriod;
    }

    public int getLookforward() {
        return 0;
    }

    public OptInputParameterInfo getOptInputParameterInfo(int index) {
        if (index <= optInputParameterInfos.length) {
            return optInputParameterInfos[index];
        }
        return null;
    }

    public OutputParameterInfo getOutputParameterInfo(int index) {
        if (index <= outputParameterInfos.length) {
            return outputParameterInfos[index];
        }
        return null;
    }

    public void setInputParameter(int index, Object array) {
        inputs[index] = (double[]) array;
    }

    public void setOptInputParameter(int index, Object value) {
        timePeriod = (Integer) value;
    }

    public void setOutputParameter(int index, Object array) {
        outputs[index] = (double[]) array;
    }
}


Best regards
bojno


 
 Post subject: Re: Annotation @Library using by indicators Post rating: 2   New post Posted: Tue 11 Feb, 2014, 11:19 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The issue has been registered.


 
 Post subject: Re: Annotation @Library using by indicators Post rating: 0   New post Posted: Thu 20 Feb, 2014, 18:50 

User rating: 0
Joined: Tue 18 Jun, 2013, 21:55
Posts: 14
Location: Slovakia, Nitra
Greetings,

seems as working perfectly already... I don't press the button "Is Answered" yet but later. I will see wheter I am not wrong again...

Best regards
bojno


 

Jump to:  

cron
  © 1998-2024 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