Dukascopy
 
 
Wiki JStore Search Login

Multiple time frames in The custom one indicator?
 Post subject: Multiple time frames in The custom one indicator? Post rating: 0   New post Posted: Thu 28 Jan, 2016, 02:31 

User rating: 0
Joined: Mon 25 Jan, 2016, 05:59
Posts: 14
Location: China,
Hi everyone, I want to much time frame frame code custom indicators .
Who can help me thank you very much


/*************
* CALCULATE *
*************/

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;


ma.setOptInputParameter(0, maPeriod);
ma.setOptInputParameter(1, maType.ordinal());

if(otherPeriodBars.length - ma.getLookback() < 0) {
return new IndicatorResult(startIndex, len);
}
double[] maOutput = new double[otherPeriodBars.length - ma.getLookback()];

ma.setInputParameter(0, getMAInputs(otherPeriodBars));
ma.setOutputParameter(0, maOutput);

ma.calculate(0, otherPeriodBars.length - 1);

int lb = ma.getLookback();
int other_idx = otherPeriodBars.length - 1;
int main_idx = mainBars.length - 1;

OUTER:
while(other_idx >= lb) {
while(main_idx >= lb && otherPeriodBars[other_idx].getTime() <= mainBars[main_idx].getTime()) {
output[0][main_idx - lb] = maOutput[other_idx - lb];
main_idx--;
}
other_idx--;
}

return new IndicatorResult(startIndex, len);
}

public double[] getMAInputs(IBar[] bars) {
double[] maInputs = new double[bars.length];

for(int i = 0; i < bars.length; i++) {
switch(selectedPrice) {
case 0:
maInputs[i] = bars[i].getOpen();
break;
case 1:
maInputs[i] = bars[i].getClose();
break;
case 2:
maInputs[i] = bars[i].getHigh();
break;
case 3:
maInputs[i] = bars[i].getLow();
break;
}
}

return maInputs;
}


/***********
* START *
***********/

public void onStart(IIndicatorContext context) {

this.console = context.getConsole();

int[] priceValues = {0, 1, 2, 3};
String[] priceNames = {"Open", "Close", "High", "Low"};

int[] maTypeValues = new int[MaType.values().length];
String[] maTypeNames = new String[MaType.values().length];
for (int i = 0; i < maTypeValues.length; i++) {
maTypeValues[i] = i;
maTypeNames[i] = MaType.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";

inputParameterInfo = new InputParameterInfo("Other period bars", InputParameterInfo.Type.BAR);
inputParameterInfos = new InputParameterInfo[] {
new InputParameterInfo("Main", InputParameterInfo.Type.BAR),
inputParameterInfo,
};


 

Jump to:  

  © 1998-2024 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