In SMA case there is one optional parameter - time period, so you add SMA indicator with optional input parameters in the following way:
int smaPeriod = 30;
chart.addIndicator(indicator, new Object[] { smaPeriod})
In general case you can check optional input parameters of an indicator by doing the following:
print("count: " + indicatorInfo.getNumberOfOptionalInputs());
for (int i = 0; i < indicatorInfo.getNumberOfOptionalInputs(); i++){
print( i + ": name = '"+ indicator.getOptInputParameterInfo(i).getName() + "' type = "+ indicator.getOptInputParameterInfo(i).getType());
}