Hello everyone My English is very poor, please forgive me. I want to implement a multiple time frame of reference to a custom indicator. “MyCustomindicator”(file.jfx)My own definition of the indicator.
Part of the code: ====================================================================== public class MYindicatorTimeFrame implements IIndicator {
// //String indName = context.getIndicators().registerCustomIndicator(MyCustomindicator.class); //console.getOut().println("MyCustomindicator" + indName ); //IIndicator myCustom = context.getIndicators().getIndicator(MyCustomindicator); //chart.addIndicator(MyCustomindicator, new Object[]{10}); //File compiledCustomIndcatorFile = new File("/Users/Documents/java/MyCustomindicator.jfx"); //String indicatorName = context.getIndicators().<span class="posthilit">registerCustomIndicator</span>(MyCustomindicator); private IndicatorInfo indicatorInfo; // INPUTS private InputParameterInfo[] inputParameterInfos; private IBar[] mainBars; private IBar[] otherPeriodBars; private InputParameterInfo inputParameterInfo; // OPT INPUTS private OptInputParameterInfo[] optInputParameterInfos; private MyCustomindicatorType myCustomindicatorType; private int myCustomindicatorPeriod; private int selectedPrice = 1; // OUTPUTS private OutputParameterInfo[] outputParameterInfos; private double[][] output; private int HIGH = 0; private int LOW = 1; // CONTEXT private IConsole console; private IIndicator MyCustomindicator; // This is my custom indicator public int getLookback() { return maPeriod - 1; } public int getLookforward() { return 0;
public IndicatorResult calculate(int startIndex, int endIndex) { if (startIndex - getLookback() < 0) { startIndex -= startIndex - getLookback(); } if (startIndex > endIndex) { return new IndicatorResult(0, 0); } int len = endIndex - startIndex + 1; MyCustomindicator.setOptInputParameter(0, myCustomindicatorPeriod); MyCustomindicator.setOptInputParameter(1, myCustomindicatorType.ordinal()); if(otherPeriodBars.length - MyCustomindicator.getLookback() < 0) { return new IndicatorResult(startIndex, len); } double[] MyCustomindicatorOutput = new double[otherPeriodBars.length - MyCustomindicator.getLookback()]; MyCustomindicator.setInputParameter(0, getMyIndicatorInputs(otherPeriodBars)); MyCustomindicator.setOutputParameter(0, MyCustomindicatorOutput); MyCustomindicatorr.calculate(0, otherPeriodBars.length - 1); int lb = MyCustomindicator.getLookback(); int other_idx = otherPeriodBars.length - 1; int main_idx = mainBars.length - 1;
public void onStart(IIndicatorContext context) { this.console = context.getConsole(); int[] priceValues = {0, 1, 2, 3}; String[] priceNames = {"A", "B", "C", "D"};
int[] myCustomindicatorTypeValues = new int[myCustomindicatorType.values().length]; String[] myCustomindicatorTypeNames = new String[myCustomindicatorType.values().length]; for (int i = 0; i < myCustomindicatorTypeValues.length; i++) { myCustomindicatorTypeValues[i] = i; myCustomindicatorTypeNames[i] = myCustomindicatorType.values()[i].name(); }
int[] periodValues = new int[10]; String[] periodNames = new String[10]; periodValues[0] = 0; periodNames[0] = "1 Min"; periodValues[1] = 1; periodNames[1] = "5 Mins"; periodValues[2] = 2; periodNames[2] = "10 Mins"; periodValues[3] = 3; periodNames[3] = "15 Mins"; periodValues[4] = 4; periodNames[4] = "30 Mins"; periodValues[5] = 5; periodNames[5] = "Hourly"; periodValues[6] = 6; periodNames[6] = "4 Hours"; periodValues[7] = 7; periodNames[7] = "Daily"; periodValues[8] = 8; periodNames[8] = "Weekly"; periodValues[9] = 9; periodNames[9] = "Monthly";
=================================================== Thanks
|