Introsort/sort_MqlRates.mq5
amrali ce52e512cc
2026-07-26 02:54:00 +03:00

27 lines
1.1 KiB
MQL5

//+------------------------------------------------------------------+
//| sort_MqlRates.mq5 |
//| Copyright © 2025, Amr Ali |
//| https://www.mql5.com/en/users/amrali |
//+------------------------------------------------------------------+
#include "Introsort.mqh"
//+------------------------------------------------------------------+
//| custom comparison functions Less. |
//+------------------------------------------------------------------+
bool Less(MqlRates &a, MqlRates &b)
{ return a.open < b.open; }
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnStart()
{
MqlRates Rates[];
CopyRates(_Symbol, PERIOD_CURRENT, 0, 5, Rates);
ArrayPrint(Rates);
Introsort(Rates);
ArrayPrint(Rates);
}
//+------------------------------------------------------------------+