MT4 Bug?? - iLowest function

 
hello

recently I experienced sth really strange while programming an EA. The thing is that I set the stop like this
// stop = lowest Low of the last 3 bars
    if(dir == OP_BUY)
    {
      stopLoss = Low[iLowest(Symbol(), 0, PRICE_LOW, 3, 1)];
    }
     
    else if(dir == OP_SELL)
    {
      stopLoss = High[iHighest(Symbol(), 0, PRICE_HIGH, 3, 1)];
    }
OK...well that searches for the lowest LOW in the last 3 bars (for a BUY)
Attached a screenshot what it looks like. The only problem is that I think the iLowest function is buggy: See, in the first case it sets the stop correctly (the lowest point in the last three bars), in the second case, however, it doesn't set it correctly, it claims the that the lowest point is the LOW of the one bar with the arrow but it should be the bar directly before (one after the one with the arrow).
MT4Developers, Could you please have a look and tell me if I am right and iLowest doesn't work as it should or if I am just doing sth. wrong?

 
RTFM

int iLowest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)
Returns the shift of the least value over a specific number of periods depending on type.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
type - Series array identifier. It can be any of Series array identifier enumeration values.
count - Number of periods (in direction from the start bar to the back one) on which the calculation is carried out.
start - Shift showing the bar, relative to the current bar, that the data should be taken from.
Sample:
// calculating the lowest value on the 10 consequtive bars in the range
// from the 10th to the 19th index inclusive on the current chart
double val=Low[iLowest(NULL,0,MODE_LOW,10,10)];


Where you see Price_Low or Price_High ?
 
hi Rosh,

thank you very much for your quick reply. I see what is wrong :D that's stupid. . .well...only the fact that is sometimes worked and sometimes not made me think it might be a bug. Well...great, now I know why it doesn't work :)

Take care.

EDIT: Yeah...now it works, thanks a lot.
 
Rosh:
RTFM

int iLowest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)
Returns the shift of the least value over a specific number of periods depending on type.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
type - Series array identifier. It can be any of Series array identifier enumeration values.
count - Number of periods (in direction from the start bar to the back one) on which the calculation is carried out.
start - Shift showing the bar, relative to the current bar, that the data should be taken from.
Sample:
// calculating the lowest value on the 10 consequtive bars in the range
// from the 10th to the 19th index inclusive on the current chart
double val=Low[iLowest(NULL,0,MODE_LOW,10,10)];


Where you see Price_Low or Price_High ?
 

I would like to get the Lowest value of the bars between bar 7500 and bar 8000 of the EA. My current bar is Bar 8000, therefore I need to get the Lowest value of the PREVIOUS 500 bars. I tried double val=Low[iLowest(NULL,0,MODE_LOW,500,500)]; double val=Low[iLowest(NULL,0,MODE_LOW,500,0)];double val=Low[iLowest(NULL,0,MODE_LOW,500,8000)];double val=Low[iLowest(NULL,0,MODE_LOW,8000,500)];

Please help, I can't get this to work!!!

Rosh:
RTFM

int iLowest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)
Returns the shift of the least value over a specific number of periods depending on type.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
type - Series array identifier. It can be any of Series array identifier enumeration values.
count - Number of periods (in direction from the start bar to the back one) on which the calculation is carried out.
start - Shift showing the bar, relative to the current bar, that the data should be taken from.
Sample:
// calculating the lowest value on the 10 consequtive bars in the range
// from the 10th to the 19th index inclusive on the current chart
double val=Low[iLowest(NULL,0,MODE_LOW,10,10)];


Where you see Price_Low or Price_High ?
 

If you want to get the Lowest value of the bars between bar 7500 and bar 8000 of the EA and current bar is Bar 8000,use

double val=Low[iLowest(NULL,0,MODE_LOW,500,7500)];
It search from bar with index 7500 towards to bar with index 8000 (7500+500).


See documentation and 'please help with finding candle body high and lows in a range.'
 

Hi Roch,

Still not working. Please look at the attached document.

int start()

{

static int shift;

double val;

if((Bars>=7250)&&(shift == 0))

{

shift = Bars;

val = High[iHighest(NULL,0,MODE_HIGH,46,7204)];

Print("val ",val);

}

}

// the end.

The value returned is 0.9581 instead of 1.2337

 
There is mistake in you explanation. See also Tester in the Terminal MetaTrader 4: It Should Be Known

 
See also my explanation on similar thread: 'Problem with iHighest -- bug?'
Reason: