AROON
Download scriptTo implement the Lowest and Highest methods, we need to first ensure that the arrays are set up correctly with appropriate values for calculating the minimum or maximum. Here's a step-by-step breakdown:
Assumptions:
- Array Length: The length of the array is determined by the input
count. - Symbol Functionality: We assume
Symbol()provides some numeric value that can be adjusted by subtractingPERIOD_CURRENT. - Array Initialization: Arrays are initialized with a specific pattern or values based on the context.
- Constants:
PERIOD_CURRENTis a constant used to adjust values retrieved fromSymbol().WRONG_VALUErepresents an error condition, like when calculations cannot be performed due to incorrect inputs.
Implementation:
#include <vector>
#include <algorithm> // for std::min_element and std::max_element
const int PERIOD_CURRENT = 10; // Example constant value
const double WRONG_VALUE = -1.0e99; // Represents an erroneous or invalid result
double Symbol() {
// Simulating a function that returns some symbolic numeric value.
return 100.0; // Placeholder value for demonstration purposes
}
void ArraySetAsSeries(std::vector<double>& array, bool flag) {
// Assuming this sets up the array in a way it's used later.
// This is just a placeholder implementation.
if (flag) {
double baseValue = Symbol() - PERIOD_CURRENT;
for (size_t i = 0; i < array.size(); ++i) {
array[i] = baseValue + static_cast<double>(i); // Example pattern
}
}
}
int Highest(const int count, const int start) {
if (count <= 0 || start < 0) return WRONG_VALUE;
std::vector<double> array(count);
ArraySetAsSeries(array, true);
auto it = std::max_element(array.begin() + start, array.begin() + start + count);
return (it != array.end()) ? static_cast<int>(*it + start) : WRONG_VALUE;
}
int Lowest(const int count, const int start) {
if (count <= 0 || start < 0) return WRONG_VALUE;
std::vector<double> array(count);
ArraySetAsSeries(array, true);
auto it = std::min_element(array.begin() + start, array.begin() + start + count);
return (it != array.end()) ? static_cast<int>(*it + start) : WRONG_VALUE;
}
Key Points:
- Validation: We check if
countandstartare valid to prevent out-of-bounds errors. - Array Initialization:
ArraySetAsSeriessets up the array with a specific pattern based on a base value derived fromSymbol(). - Algorithm: Use
std::max_elementandstd::min_elementto find the highest or lowest value within the specified range in the array. - Error Handling: Return
WRONG_VALUEif inputs are invalid, ensuring robustness against incorrect usage.
This code assumes you have some mechanism to define PERIOD_CURRENT, and that Symbol() returns a valid numeric type. Adjust these parts as necessary to fit your specific requirements.
Price Data Components
12
Views
0
Downloads
0
Favorites
AROON
ÿþ/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
/ / | A R O O N . m q 5 |
/ / | C o p y r i g h t 2 0 1 8 , M e t a Q u o t e s S o f t w a r e C o r p . |
/ / | h t t p s : / / m q l 5 . c o m |
/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
# p r o p e r t y c o p y r i g h t "