//+------------------------------------------------------------------+
//| GnomeSort.mq5 |
//| 2019-2021, dimitri pecheritsa |
//| mql5.com/en/users/dmipec |
//|------------------------------------------------------------------|
//| f | script program start function |
//|------------------------------------------------------------------|
//| use | gnome sort example. sort market watch symbols by spread |
//+------------------------------------------------------------------+
#include <Mqh\Algorithms\SortGnome\GnomeSort.mqh>
#include <Mqh\Algorithms\SortGnome\Functions.mqh>
void OnStart(void)
{
//--- load symbols from the warket watch window
string symbols[];
SymbolsLoad(symbols);
//--- load spreads of the symbols
int keys[];
SymbolKeysSpread(symbols,keys);
//--- sort symbols by spread in accending order
ArraySort(keys,symbols,new CGnomeSort<int,string>);
//--- print a table of symbols to check result
SymbolsPrint(symbols);
}
//--------------------------------------------------------------------
// symbol | spread | point
//--------------------------------------------------------------------
// BRENT | 6 | 0.01
// EURUSD | 16 | 1E-05
// .US30Cash | 16 | 0.1
// TSLA | 47 | 0.01
// XAUUSD | 300 | 0.001
// USDRUB | 672 | 0.0001
// BTCUSD | 13833 | 0.01
//--------------------------------------------------------------------
Comments