Hello everyone, i start this topic as i'm an absolute newbie in Metatrader and his language; i'm converting several EA from mq4 to C# and debugging the expert advisors i've been able to convert almonst everything but i have some doubts about the array Low[] and High[]: i took the definition of Low:
double Low[]
Series array that contains the lowest prices of each bar of the current chart.
this is totally nonsense to me: what means "the lowest prices of each bar"? a bar has only one Low!!!
and how many elements are in that array? how they are ordered (if are ordered)??
thanks in advance for every clarification :)
Low[0] is the low of the current bar
Low[1] is the low of the last closed bar
Low[2] is the low of the bar before that
etc etc
- Why did you post your MT4 question in the Root / MT5 General
section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - LandauMT4: nd how many elements are in that array? how they are ordered (if are ordered)??Low[]/High[] is as series as Keith explained. There is no such concept in your DLL. There, P[0] is the oldest and P[Bars-1] the newest.
- LandauMT4: this is totally nonsense to me: what means "the lowest prices of each bar"? a bar has only one Low!!!Of course, it's a typo.
Low[0] is the low of the current bar
Low[1] is the low of the last closed bar
Low[2] is the low of the bar before that
etc etc
Hello Keith, many thanks: this is ok and make sense. so the order is from left (the running candle) to right (the most old candle).
The documentation says that the size of the array Low[] is the number of candles in the graph: i suppose there is a limit anyways (imagine to manage the low[] array with decades of candles with 1 minute as timeframe): do you know what is that limit.
Many thanks again, cheers
- Why did you post your MT4 question in the Root / MT5 General
section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - Low[]/High[] is as series as Keith explained. There is no such concept in your DLL. There, P[0] is the oldest and P[Bars-1] the newest.
- Of course, it's a typo.
1- my fault, sorry
2- my DLL? what you mean?
3- ok
Bye and thanks
Hello, can someone confirm me that the Lowest function returns the index of bar where there is the lowest LOW in the range of bars specified???
this is how i converted the Lowest function:
int Lowest(int count, int startindex, List<Candle> bars)
{
int lowposition = -1;
decimal min = decimal.MaxValue;
int i = 0, j = 0;
for (i = startindex; j < count; i++, j++)
{
var tmpmin = bars[i].Low;
if (tmpmin < min)
{
min = tmpmin;
lowposition = i;
}
}
return lowposition;
}
- www.mql5.com
i really can't understand this line:
val=Low[Lowest(NULL,0,MODE_LOW,ExtDepth,shift)];
Lowest(..) return the index of the candle with the lowest Low in the range specified (inside the bars array)
but why is used to index the array Low?? the array low is not bars, so the indexing is inconsistet....
val=Low[Lowest(NULL,0,MODE_LOW,ExtDepth,shift)];
but why is used to index the array Low?? the array low is not bars, so the indexing is inconsistet....
Low[] is an array of bar low prices. Low[0] is the low price of the current bar, Low[1] is the low price of the previous bar, etc. Similarly, High[0] is the high of the current bar etc.
iLowest() scans the bar history for the lowest of a set of values, and returns the corresponding index. Your example call to iLowest does the following:
- Starts at the bar with offset shift
- Scans a total of ExtDepth bars
- Looks for the one out of the ExtDepth bars with the lowest low value, and returns its zero-based index
For example, let's say that the lows of the last 10 bars are as follows (in MT4 order, with #0 meaning the current bar):
- #0: 1.10767
- #1: 1.10721
- #2: 1.10714
- #3: 1.10739
- #4: 1.10693
- #5: 1.10702
- #6: 1.10730
- #7: 1.10688
- #8: 1.10709
- #9: 1.10752
You then call iLowest with shift=2 and ExtDepth=5. MT4 will scan bars #2 through #6 inclusive. iLowest() will return 4, because 1.10693 is the lowest of those values. Doing Low[4] then gives you the actual low price of 1.10693.
Part of the confusion/complexity is that iLowest() doesn't necessarily find the lowest low. It's not scanning the Low[] array; it's scanning the bar history. If you call iLowest() with MODE_HIGH rather than MODE_LOW, for example, then it will return the index of the bar with the lowest high value rather than the lowest low value.
Similarly, having found the lowest low (or lowest high, or whatever), you may not necessarily want to know what the low value is. You might instead want to know the close price of the bar where the lowest low occurred.That would be Close[iLowest(..., MODE_LOW, ...)]
To put it another way: retrieval of a lowest-low price is a two-part process, involving use of iLowest() to get a bar index and then extracting that value from the Low[] array. It's a two-part process instead of a single call because getting the lowest low price is by far the most common use-case, but there are also scenarios such as wanting to know the close price of the bar where the lowest-low occurred.
Or another way: your C# implementation of Lowest() is less flexible than MQL4's iLowest(). Your implementation is like a version of MQL4's iLowest() which can only be called with MODE_LOW, not with MODE_HIGH or MODE_CLOSE etc.
- www.mql5.com
//+------------------------------------------------------------------+ //| Find Lowest Low.mq4 | //| Copyright 2019, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2019, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- int lowest_index=iLowest(Symbol(),PERIOD_CURRENT,MODE_LOW,WHOLE_ARRAY,0); double lowest_low=Low[lowest_index]; Print("The bar number with the lowest low: "+(string)lowest_index); Print("The Lowest Low: "+DoubleToStr(lowest_low)); } //+------------------------------------------------------------------+
Hi, really many many many thanks for your detailed reply.
Maybe there is a misunderstanding: the lowest function operates on the bars array or on the Low[] array?
i explain better:
i have a list of candles called bars
every minute happens that:
1-i add a new candle to this list (because my timeframe is 1 minute)
2- i calculate the Low and High arrays like so:
Low = new decimal[bars.Count];
High = new decimal[bars.Count];
for (int i = 0; i < bars.Count; i++)
{
Low[i] = bars[i].Low;
High[i] = bars[i].High;
}
3- i calculate val = Low[Lowest(_ExtDepth, shift,bars)];
as you can see i pass the bars to my Lowest function, and bars is a list of candles
you wrote:
For example, let's say that the lows of the last 10 bars are as follows (in MT4 order, with #0 meaning the current bar)
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
is this true?
Cheers.
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone, i start this topic as i'm an absolute newbie in Metatrader and his language; i'm converting several EA from mq4 to C# and debugging the expert advisors i've been able to convert almonst everything but i have some doubts about the array Low[] and High[]: i took the definition of Low:
double Low[]
Series array that contains the lowest prices of each bar of the current chart.
this is totally nonsense to me: what means "the lowest prices of each bar"? a bar has only one Low!!!
and how many elements are in that array? how they are ordered (if are ordered)??
thanks in advance for every clarification :)