Edited: Looks like I have cracked this, code below - but constructive enhancements/comments are welcome.
I am trying to retrieve the highest value from the highest bar within a given period.
If I specify from 03:00 to 06:00 what I get back are prices for close to now (say 11:00). What I seem to be retrieving are figures from close to now.
I am new to MQL5 and it's vast array of features, but not new to C & C++.
/* range_high()
*
* Discovers the highest bar value for the period passed as parameters
*
* Parameters: symbol string like "GBPUSD"
* from: datetime, start of period requested - should be within a day
* to: datetime, end of period requested - should be within same day
* timeframe: ENUM_TIMEFRAMES being evaluated
*
* Returns: double, on failure 0
* on success the highest bar value for the period requested
*/double range_high(string symbol, datetime from, datetime to, ENUM_TIMEFRAMES timeframe)
{
int highest_candle;
MqlRates prices[];
double high_range[];
double high_val = 0;
int n;
ArraySetAsSeries(prices, true);
ArraySetAsSeries(high_range, true);
n = CopyHigh(symbol, timeframe, from, to, high_range);
if( n > 0 ) {
highest_candle = ArrayMaximum(high_range, 0);
n = CopyRates(symbol, timeframe, from, to, prices);
if( n > 0 )
high_val = prices[highest_candle].high;
} else
Print(__FUNCTION__, ": Couldn't copy from ", from, ", to ", to);
return( n > 0 ? high_val : 0 );
}
Hello All,
Edited: Looks like I have cracked this, code below - but constructive enhancements/comments are welcome.
I am trying to retrieve the highest value from the highest bar within a given period.
If I specify from 03:00 to 06:00 what I get back are prices for close to now (say 11:00). What I seem to be retrieving are figures from close to now.
I am new to MQL5 and it's vast array of features, but not new to C & C++.