I want to make a function that can automatically sort according to the high, low, open, and close values in the mqlrates structure, but when calling the function, I find that the member variable name cannot be directly used as a function parameter.

Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / History Data Structure
- www.mql5.com
History Data Structure - Data Structures - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
- Questions from Beginners MQL5 MT5 MetaTrader 5
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- Add alert + email + place tardes Zigzig indicator
Blur Darkness: I find that the member variable name cannot be directly used as a function parameter.
Correct. Pass a comparison function.
struct Less{ template <typename Datatype> bool is_before(const Datatype& a, const Datatype& b) const{return a < b;} void Less(void){} // Prevent "possible use of uninitialized variable" private: char onebyte; // Prevent "struct has no members, size assigned to 1 byte" }; struct LessRatesHigh{ bool is_before(const MqlRates& a, const MqlRates& b) const{return a.high < b.high;} void LessRatesHigh(void){} // Prevent "possible use of uninitialized variable" private: char onebyte; // Prevent "struct has no members, size assigned to 1 byte" }; ⋮ LessRatesHigh comp; data.Get_struct_sort(rates, comp); ⋮ template <typename Type_Name, typename BinaryPredicate> void getdata::Get_struct_sort(Type_Name &array[],const BinaryPredicate& comp) ⋮ if(comp.is_before(array[k+1], array[k]) // if(array[k].name> array[k + 1].name

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