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.

Indicator - Instrument input change on the go
 Post subject: Indicator - Instrument input change on the go Post rating: 0   New post Posted: Tue 22 Aug, 2017, 21:05 

User rating: 0
Joined: Tue 15 Sep, 2015, 20:14
Posts: 4
Location: Poland,
Hello,
I'm trying to make Correlation indicator of two Intruments.

First one is static (for example EURUSD)
Second one is variable (for example GBPUSD).

When I put indicator everything is OK.
But when I change second Instrument, indicator stop working.

        inputParameterInfos = new InputParameterInfo[]
        {
            new InputParameterInfo(myInstrument.toString(),
                    InputParameterInfo.Type.BAR) {{
                        setInstrument(myInstrument);
//                        setPeriod(myPeriod);
//                        setOfferSide(mySide);
                        }},
            new InputParameterInfo(instrumentCorrelation.toString(),
                    InputParameterInfo.Type.BAR) {{
                        setInstrument(instrumentCorrelation);
//                        setPeriod(myPeriod);
//                        setOfferSide(mySide);
                        }},
        };

        optInputParameterInfos = new OptInputParameterInfo[]
        {
            new OptInputParameterInfo("Correlation Instrument", OptInputParameterInfo.Type.OTHER,
                  new IntegerListDescription(instrumentCorrelation.ordinal(), instrumentValues, instrumentNames))
        };

    public void setOptInputParameter(int index, Object value)
    {
        switch (index)
        {
        case 0:
            OptInputDescription descr = optInputParameterInfos[index].getDescription();
            int[] values = ((IntegerListDescription) descr).getValues();
            int instr = -1;
           
            for (int i = 0; i < values.length; i++)
            {
                if (values[i] == (Integer) value)
                {
                    instr = values[i];
                    break;
                }
            }
           
            if (instr < 0)
            {
                // value not found
                instr = values[0];
            }
           
            if (instr >= 0)
            {
                inputParameterInfos[1].setInstrument(Instrument.values()[instr]);
            }
            else
            {
                inputParameterInfos[1].setInstrument(null);
            }
           
            writeMessage ("inputParameterInfos[1] " + inputParameterInfos[1].getInstrument().toString());
            break;

            default:
                throw new ArrayIndexOutOfBoundsException(index);
        }
    }


Any ideas how to fix this? :)


 
 Post subject: Re: Indicator - Instrument input change on the go Post rating: 0   New post Posted: Mon 28 Aug, 2017, 10:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
In this forum we try to focus on JForex API issues rather than programming problems.
There are a number of strategies and indicators available from https://www.dukascopy.com/jstore/
Alternatively it is possible to to request external programmer to implement a strategy or indicator for you:
https://www.dukascopy.com/fxcomm/member ... am_service


 

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