You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Maybe there is a misunderstanding: the lowest function operates on the bars array or on the Low[] array?
so it seems that Lowest must operate on the Low[] (wich is an array of prices) and not bars(wich is a list of candles): indeed is a nonsense index the Low array using an index extracted from bars
No, iLowest() operates on the list of candles. Which candle value it looks at depends on the type parameter: MODE_LOW for low prices, MODE_HIGH for high prices.
My example was a slightly simplified one, assuming that iLowest() was being called with MODE_LOW as in your example - before moving on to discussion of other, more complex scenarios.
Thanks again, but Low[] is what? an array of candles or an array of prices (=double)?
It's an array of prices - as I said in my earlier message.
https://docs.mql4.com/predefined
lets's say we have a bars like so
candle0=[O=1.34, H=1.78, L=1.31, C=1.56] <- more recent candle
candle1=[O=1.21, H=1.90, L=1.20, C=1.69]
candle2=[O=1.11, H=1.30, L=1.10, C=1.12]
candle3=[O=1.09, H=1.44, L=1.01, C=1.15]
candle4=[O=1.67, H=1.91, L=1.55, C=1.88]
candle5=[O=1.98, H=2.20, L=1.97, C=2.43]
candle6=[O=2.43, H=2.53, L=2.39, C=2.44]
candle7=[O=1.88, H=1.99, L=1.87, C=1.88]
candle8=[O=1.71, H=1.81, L=1.56, C=1.80]
candle9=[O=1.66, H=1.94, L=1.17, C=1.56]
in such case in my opinion Low = [1.31, 1.20, 1.10, 1.01, 1.55, 1.97, 2.39, 1.87, 1.56, 1.17]
right?
so Lowest(NULL,0,MODE_LOW,5,3) should return 3 because 3 is the position (inside bars) of the candle with the lowest low (1.01)
then if val = Low[Lowest(NULL,0,MODE_LOW,5,3) ]
then val= 1.01...
and what is this stuff? what does it represent? i don't understand.. its' more easy return directly the lowes low...
in such case in my opinion...
Yes, the Low[] array will contain the values you list and, yes, your example of iLowest() will then return 3.
(Taking a different example which doesn't involve the absolutely lowest value in the data set, iLowest(NULL, 0, MODE_LOW, 4, 5) would return 8.)
See my original message for an explanation of why MT4 does this, instead of just giving you a single function which returns the price of the lowest-low.
Yes, the Low[] array will contain the values you list and, yes, your example of iLowest() will then return 3.
(Taking a different example which doesn't involve the absolutely lowest value in the data set, iLowest(NULL, 0, MODE_LOW, 4, 5) would return 8.)
See my original message for an explanation of why MT4 does this, instead of just giving you a single function which returns the price of the lowest-low.
yes correct, it would return 8
ok the reason is "there are also scenarios such as wanting to know the close price of the bar where the lowest-low occurred."
this is not my case because the indicator i must convert uses only iLowest with the option MODE_LOW and iHighest with the option MODE_HIGH , this is why i don't consider that parameter in my C# conversion.
i can't get the correct result (i have some excel files with the calculator's result to make a comparison), maybe the error is elsewhere...
my iHighest conversion is:
[code]
private int Highest(int count, int startindex, List<Candle> bars)
{
int highposition = -1;
decimal max = decimal.MinValue;
int i = 0, j = 0;
for (i = startindex; j < count; i++, j++)
{
var tmpmax = bars[i].High;
if (tmpmax > max)
{
max = tmpmax;
highposition = i;
}
}
return highposition;
}
[/code]