If you mean Price Action Channel indicator
here is source code of my custom:
/**
* Copyright 2010 LorencSoftware. All rights reserved.
* LORENCSOFTWARE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package jforex;
import com.dukascopy.api.IBar;
import com.dukascopy.api.indicators.*;
import java.awt.Color;
public class LS_I_PAC implements IIndicator {
public static final int FALSE = 0;
public static final int TRUE = 1;
public static final String name = "LS_I_PAC";
public static final String group = "LorencSoftware.indicators";
private int period;
private boolean includeCurrentBar;
private double[][] outputs = new double[2][];
private IBar[] inputs = null;
private IndicatorInfo indicatorInfo;
private InputParameterInfo inputParameterInfo;
private OptInputParameterInfo[] optInputParameterInfos;
private OutputParameterInfo[] outputParameterInfos;
public void onStart(IIndicatorContext context) {
indicatorInfo = new IndicatorInfo(name, name, group, true, false, false, 1, 2, 2);
inputParameterInfo = new InputParameterInfo("Price chart", InputParameterInfo.Type.BAR);
OptInputParameterInfo opt_period = new OptInputParameterInfo("Period",
OptInputParameterInfo.Type.OTHER, new IntegerRangeDescription(5, 1, 100, 1));
int[] opt_includeCurrentBar_intArray = new int[]{FALSE, TRUE};
String[] opt_includeCurrentBar_stringArray = new String[]{"false", "true"};
IntegerListDescription opt_includeCurrentBar_intListDesc =
new IntegerListDescription(0, opt_includeCurrentBar_intArray, opt_includeCurrentBar_stringArray);
OptInputParameterInfo opt_includeCurrentBar =
new OptInputParameterInfo("Include current bar", OptInputParameterInfo.Type.OTHER, opt_includeCurrentBar_intListDesc);
optInputParameterInfos = new OptInputParameterInfo[2];
optInputParameterInfos[0] = opt_period;
optInputParameterInfos[1] = opt_includeCurrentBar;
OutputParameterInfo out_highestHigh = new OutputParameterInfo("Highest high",
OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.LINE);
out_highestHigh.setColor(Color.GREEN);
OutputParameterInfo out_lowestLow = new OutputParameterInfo("Lowest low",
OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.LINE);
out_lowestLow.setColor(Color.RED);
outputParameterInfos = new OutputParameterInfo[2];
outputParameterInfos[0] = out_highestHigh;
outputParameterInfos[1] = out_lowestLow;
}
public IndicatorResult calculate(int startIndex, int endIndex) {
if (startIndex - getLookback() < 0) {
startIndex -= startIndex - getLookback();
}
int i, j;
for (i = startIndex, j = 0; i <= endIndex; i++, j++) {
IBar[] data;
if (includeCurrentBar) {
data = subArrayOfLastValues(inputs, i, period);
} else {
data = subArray(inputs, i-period, (i-1));
}
double highestHigh = Double.MIN_VALUE;
double lowestLow = Double.MAX_VALUE;
for (int ii = 0; ii<data.length; ii++) {
IBar bar = data[ii];
if (bar.getHigh()>highestHigh) { highestHigh = bar.getHigh(); }
if (bar.getLow()<lowestLow) { lowestLow = bar.getLow(); }
}
outputs[0][j] = highestHigh;
outputs[1][j] = lowestLow;
}
return new IndicatorResult(startIndex, j);
}
//SET PARAMETERS
public void setOptInputParameter(int index, Object value) {
Integer i_value = (Integer) value;
if (index == 0) {
period = i_value;
}
if (index == 1) {
if (i_value == FALSE) {
includeCurrentBar = false;
}
if (i_value == TRUE) {
includeCurrentBar = true;
}
}
}
public void setOutputParameter(int index, Object array) {
if (index < outputs.length) {
outputs[index] = (double[])array;
}
}
public void setInputParameter(int index, Object array) {
inputs = (IBar[]) array;
}
//GET PARAMETERS
public IndicatorInfo getIndicatorInfo() {
return indicatorInfo;
}
public InputParameterInfo getInputParameterInfo(int index) {
return inputParameterInfo;
}
public OptInputParameterInfo getOptInputParameterInfo(int index) {
if (index < optInputParameterInfos.length) {
return optInputParameterInfos[index];
}
return null;
}
public OutputParameterInfo getOutputParameterInfo(int index) {
if (index < outputParameterInfos.length) {
return outputParameterInfos[index];
}
return null;
}
//LOOKBACK & LOOKFORWARD
public int getLookback() {
if (includeCurrentBar) {
return period-1;
} else {
return period;
}
}
public int getLookforward() {
return 0;
}
//CUSTOM METHODS
private IBar[] subArray(IBar[] sourceArray, int startingIndex, int endingIndex) {
IBar[] result = null;
result = new IBar[(endingIndex-startingIndex)+1];
int j = result.length-1;
for (int i = startingIndex; i<=endingIndex; i++) {
result[j] = sourceArray[i];
j--;
}
return result;
}
private IBar[] subArrayOfLastValues(IBar[] sourceArray, int lastSourceArrayPosition, int countOfLastValues) {
IBar[] result = null;
result = new IBar[countOfLastValues];
for (int i = 0; i<countOfLastValues; i++) {
result[i] = sourceArray[lastSourceArrayPosition-i];
}
return result;
}
}
and here is example how to get the indicator values inside of strategy for example:
private double PAC_high(Instrument instrument, Period period, OfferSide offerSide, int lookBack, boolean includeLastBar, long time) Exception {
int includeLastBar_int = 0;
if (includeLastBar) { includeLastBar_int=1; }
double[] values = (double[]) indicators.calculateIndicator(
instrument,
period,
new OfferSide[] {offerSide},
"LS_I_PAC",
new AppliedPrice[] {AppliedPrice.CLOSE},
new Object[] {lookBack, includeLastBar_int},
Filter.WEEKENDS,
1,
time,
0)[0];
Double value = values[0];
return value;
}
private double PAC_low(Instrument instrument, Period period, OfferSide offerSide, int lookBack, boolean includeLastBar, long time) Exception {
int includeLastBar_int = 0;
if (includeLastBar) { includeLastBar_int=1; }
double[] values = (double[]) indicators.calculateIndicator(
instrument,
period,
new OfferSide[] {offerSide},
"LS_I_PAC",
new AppliedPrice[] {AppliedPrice.CLOSE},
new Object[] {lookBack, includeLastBar_int},
Filter.WEEKENDS,
1,
time,
0)[1];
Double value = values[0];
return value;
}