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.

custom period for custom indicator
 Post subject: custom period for custom indicator Post rating: 0   Post Posted: Sun 02 Jun, 2013, 15:22 

User rating: 1
Joined: Wed 07 Mar, 2012, 05:56
Posts: 101
Location: New CaledoniaNew Caledonia
hello support,

i use in my strategy a converted indicator.
i define it like this :
@Configurable("lsma")
    public File jfxFile = new File("/home/eric/JForex/Indicators/iGentorLSMAEMA_v1102.jfx");

indName = indicators.registerCustomIndicator(jfxFile); 
        IIndicator indicator = indicators.getIndicator(indName);

double[][] lsma = calculateIndicatorDouble("indName",feedDescr, appliedPrice,   optInputs, 2,bar.getTime(), 0);

private double[] calculateIndicatorDouble(String indicatorName,  FeedDescriptor feedDescr, AppliedPrice appliedPrice, Object[] optInputs, int shift) throws JFException {
        IBar bar = getBar(feedDescr, 0);
        double[][] result = calculateIndicatorDouble(indName,  feedDescr, appliedPrice, optInputs, shift + 1, bar.getTime(), 0);
        return result[0];
    }

    private double[][] calculateIndicatorDouble(String indicatorName,  FeedDescriptor feedDescr, AppliedPrice appliedPrice, Object[] optInputs, int candlesBefore, long time, int candlesAfter) throws JFException {
        IndicatorInfo info = indicators.getIndicator(indName).getIndicatorInfo();

        int inputCount = info.getNumberOfInputs();

        int additionlBarCount = 0;
        int minBarCount = 1000;
        if(info.isRecalculateAll() || info.isUnstablePeriod()) {
            additionlBarCount = minBarCount - (candlesBefore + candlesAfter);
            if(additionlBarCount < 0) {
                additionlBarCount = 0;
            }
        }

        OfferSide[] offerSides = new OfferSide[inputCount];
        AppliedPrice[] appliedPrices = new AppliedPrice[inputCount];

        for(int i = 0; i < inputCount; i++) {
            offerSides[i] = feedDescr.getOfferSide();
            appliedPrices[i] = appliedPrice;
        }

        Object[] result = indicators.calculateIndicator(feedDescr, offerSides, indName, appliedPrices, optInputs, additionlBarCount + candlesBefore, time, candlesAfter);
        double[][] newResult = new double[candlesBefore + candlesAfter][result.length];

        for(int i = 0; i < result.length; i++) {
            double[] values = (double[])result[i];

            for(int j = 0; j < candlesBefore + candlesAfter; j++) {
                newResult[j][i] = values[j + additionlBarCount];
            }
        }

        return newResult;
    }


that's good and it work well. but i want to use this indicator on custom period. for example my signal is on 15 minutes timeframe but depends of my indicator on 4h timeframe.

how to chance the calculation timeframe for the indicator?

thank and sorry for my english


 
 Post subject: Re: custom period for custom indicator Post rating: 0   Post Posted: Mon 03 Jun, 2013, 07:17 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
ericbiz wrote:
for example my signal is on 15 minutes timeframe but depends of my indicator on 4h timeframe.
Both of the periods are standard ones, however for the actual custom periods you need to calculate the indicator on feed, see:
https://www.dukascopy.com/wiki/#Indicator_Calculation/Universal_price_feed


 

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