Hi,
to pass currency as optional parameter don't use OptInputParInfo.Type.CURRENCY.
Bellow is sample with modified "ENTROPY" indicator, which demonstrates how to pass an enum to the indicator.
Please consider this sample:
. . .
public void onStart(IIndicatorContext context) {
indicatorInfo = new IndicatorInfo("ENTROPY", "Calculates entropy number", "My indicators",
false, false, false, 1, 2, 1);
inputParameterInfos = new InputParameterInfo[] {new InputParameterInfo("Input data", InputParameterInfo.Type.DOUBLE)};
int[] vals = new int[Currency.values().length];
String[] valNames = new String[Currency.values().length];
int i = 0;
//prepare arrays to define currency's list
for (Currency cur : Currency.values()){
vals[i] = cur.ordinal();
valNames[i] = cur.name();
i++;
}
optInputParameterInfos = new OptInputParameterInfo[]
{new OptInputParameterInfo("Time period", OptInputParameterInfo.Type.OTHER, new IntegerRangeDescription(2, 2, 100, 1)),
//use OptInputParameterInfo type OTHER
new OptInputParameterInfo("Currency", OptInputParameterInfo.Type.OTHER, new IntegerListDescription(1, vals, valNames))
};
outputParameterInfos = new OutputParameterInfo[] {new OutputParameterInfo("out", OutputParameterInfo.Type.DOUBLE,
OutputParameterInfo.DrawingStyle.LINE)};
}
. . .
public void setOptInputParameter(int index, Object value) {
if (index == 1){
for (Currency cur : Currency.values()){
if(cur.ordinal() == (Integer)value)
//verify that an indicator have correct value
System.out.println(" cur: "+cur.name());
}
}
timePeriod = (Integer) value;
}
And here is, how you can call it from strategy
context.getIndicators().calculateIndicator(instrument,
period,
new OfferSide[] {OfferSide.BID},
"ENTROPY",
new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE},
new Object[]{1, Currency.USD.ordinal()},
1);
If you still have question, please do not hesitate to ask.