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 mix InputParameterInfo.Type in custom indicator?
 Post subject: how to mix InputParameterInfo.Type in custom indicator? Post rating: 0   New post Posted: Mon 15 Nov, 2010, 04:12 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
In a custom indicator, I am using (i) InputParameterInfo.Type.DOUBLE to allow user to choose the input price; and (ii) InputParameterInfo.Type.PRICE to access the OCHLV data as declared.

        inputParameterInfos = new InputParameterInfo[] {
         new InputParameterInfo("Input data", InputParameterInfo.Type.DOUBLE),
         new InputParameterInfo("OCHLV Price", InputParameterInfo.Type.PRICE)
        };


The problem arise when I use indicators.calculateIndicator(...) in my strategy to call this custom indicator (after registering it in runtime). Specifically, what do I put for AppliedPriice in such a situation?

For example, using this doesn't work because AppliedPrice is expecting a second element in array.
      Object[] objs = this.indicators.calculateIndicator(instrument, 
            period,
            new OfferSide[]{OfferSide.BID},
            "ABC", 
            new AppliedPrice[] {AppliedPrice.CLOSE},
            new Integer[] {20},
            Filter.WEEKENDS,
            1,
            bidBar.getTime(),
            0);   


I also tried this,
new AppliedPrice[] {AppliedPrice.CLOSE, null}

because if the indicator uses only InputParameterInfo.Type.PRICE, then we would input a null as the parameter for applied price.

In both cases, I am getting an ArrayIndexOutOfBoundsException because AppliedPrice[] has only length=1 whereas inputParameterInfos is expecting an array of length=2.


 
 Post subject: Re: how to mix InputParameterInfo.Type in custom indicator? Post rating: 0   New post Posted: Mon 15 Nov, 2010, 15:41 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Please try specifying the offerside of the second input as follows:

Object[] objs = this.indicators.calculateIndicator(instrument,
            period,
            new OfferSide[]{OfferSide.BID, OfferSide.BID},
            "ABC",
            new AppliedPrice[] {AppliedPrice.CLOSE},
            new Integer[] {20},
            Filter.WEEKENDS,
            1,
            bidBar.getTime(),
            0);


 

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