Hi all.
I try code this function from mql to JForex:
int barsCount = 10;
....
//+--------------------------------------------------------------------------------------------------------------+
void updateExtraSignal() {
//+--------------------------------------------------------------------------------------------------------------+
highPrice = High[iHighest(NULL,Period(),MODE_HIGH,barsCount,1)];
lowPrice = Low[iLowest(NULL,Period(),MODE_CLOSE,barsCount,1)];
}
I try in JForex this:
//+--------------------------------------------------------------------------------------------------------------+
public void updateExtraSignal() throws JFException {
//+--------------------------------------------------------------------------------------------------------------+
//--- Делаем выборку баров с 10-го (по barsCount) по первый бар
List<IBar> high = history.getBars(instrument, Period.FIFTEEN_MINS, OfferSide.BID, lastBarTime(), firstBarTime());
List<IBar> low = history.getBars(instrument, Period.FIFTEEN_MINS, OfferSide.BID, lastBarTime(), firstBarTime());
highPrice = high.getHigh(); //--- Получаем максимум среди high
lowPrice = low.getLow(); //--- Получаем минимум среди low
//---
return;
}
//+--------------------------------------------------------------------------------------------------------------+
//| barOpenTime. Возвращет время открытия нулевого бара в миллисекундах.
//+--------------------------------------------------------------------------------------------------------------+
public long firstBarTime() throws JFException{
//+--------------------------------------------------------------------------------------------------------------+
long time = 0;
IBar bar = history.getBar(instrument, timeFrame, OfferSide.BID, 1);
time = bar.getTime();
return (time);
}
//+--------------------------------------------------------------------------------------------------------------+
//| barOpenTime. Возвращет время открытия нулевого бара в миллисекундах.
//+--------------------------------------------------------------------------------------------------------------+
public long lastBarTime() throws JFException{
//+--------------------------------------------------------------------------------------------------------------+
long time = 0;
IBar bar = history.getBar(instrument, timeFrame, OfferSide.BID, barsCount);
time = bar.getTime();
return (time);
}
My function updateExtraSignal dont compile.
2) Next function:
in MQL:
//+--------------------------------------------------------------------------------------------------------------+
//| GetHigh. Функция сравнения баров по iHigh. Используется в GetMaximumForInterval
//+--------------------------------------------------------------------------------------------------------------+
double getHigh(int shift, int lenght, int tf) {
//+--------------------------------------------------------------------------------------------------------------+
double high;
double maxhigh = iHigh(Symbol(),tf,shift);
if (maxhigh < Point) return(0);
for (int i = shift + 1; i < shift + lenght; i++)
{
high = iHigh(Symbol(),tf,i);
if (high < Point) return(0);
if (high > maxhigh) maxhigh = high;
}
//---
return(maxhigh);
}
I try in JForex this
//+--------------------------------------------------------------------------------------------------------------+
//| getHigh. Функция сравнения баров по iHigh. Используется в GetMaximumForInterval
//+--------------------------------------------------------------------------------------------------------------+
public double getHigh(int shift, int lenght) throws JFException {
//+--------------------------------------------------------------------------------------------------------------+
double high = 0;
double maxhigh = high(shift, OfferSide.BID, Period.FIFTEEN_MINS);
if (maxhigh < point) return(0);
for (int i = shift + 1; i < shift + lenght; i++) {
high = high(i, OfferSide.BID, Period.FIFTEEN_MINS);
if (high < point) return(0);
if (high > maxhigh) maxhigh = high;
}
//---
return(maxhigh);
}
//+--------------------------------------------------------------------------------------------------------------+
//| high. Массив-таймсерия, содержащий максимальные цены каждого бара текущего графика.
//+--------------------------------------------------------------------------------------------------------------+
public double high(int index, OfferSide side, Period period) throws JFException{
//+--------------------------------------------------------------------------------------------------------------+
return history.getBar(instrument, period, side, index).getHigh();
}
Function is true?
3) And next function
in mql
//+--------------------------------------------------------------------------------------------------------------+
//| GetMaximumForInterval. Расчет интервала максимума. Используется в функции CheckForDrawdown для проверки
//| ордеров на продажу.
//+--------------------------------------------------------------------------------------------------------------+
double getMaximumForInterval(int time1, int time2) {
//+--------------------------------------------------------------------------------------------------------------+
int shift = iBarShift(Symbol(),Period(),time1,1);
int lenght = iBarShift(Symbol(),Period(),time2,1);
if ((lenght >= 0) && (shift >= 0))
{
return(getHigh(shift,lenght,Period()));
}
//---
return(0);
}
in JForex:
//+--------------------------------------------------------------------------------------------------------------+
//| GetMaximumForInterval. Расчет интервала максимума. Используется в функции CheckForDrawdown для проверки
//| ордеров на продажу.
//+--------------------------------------------------------------------------------------------------------------+
public double getMaximumForInterval(long time1, long time2) throws JFException {
//+--------------------------------------------------------------------------------------------------------------+
double result = 0;
//---
List<IBar> shift = history.getBars(instrument, Period.FIFTEEN_MINS, OfferSide.BID, time1, firstBarTime());
List<IBar> lenght = history.getBars(instrument, Period.FIFTEEN_MINS, OfferSide.BID, time2, firstBarTime());
if ((lenght >= 0) && (shift >= 0)) {
result = getHigh(shift, lenght);
}
//---
return(result);
}
This function dont compile, becose if ((lenght >= 0) && (shift >= 0)) {
Please help me find true analog mql High, iHighest, iBarShift functions.