SelectionSort

0 Views
0 Downloads
0 Favorites
SelectionSort
ÿþ//+------------------------------------------------------------------+

//|                                                SelectionSort.mq5 |

//|                                    2019-2021, dimitri pecheritsa |

//|                                         mql5.com/en/users/dmipec |

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//| script program start function                                    |

//+------------------------------------------------------------------+

//|  [use] a selection sort example. sort deals by symbol            |

//+------------------------------------------------------------------+

#include <Mqh\Algorithms\SelectionSort\SelectionSort.mqh>

#include <Mqh\Algorithms\SelectionSort\Functions.mqh>

void OnStart(void)

  {

//--- load deals from the terminal starting from the beginning of 

//2021 till current day. they will be treated as the items array by 

//the sorter

   ulong deals[];

   DealsLoad(deals,D'2021.01.01',0);

//--- create the keys array which contains the symbols of each deal 

//from the deals array, which is the basis for sorting

   string symbols[];

   DealsKeySymbol(deals,symbols);

//--- sort deals by symbols in descending order with the selection 

//sort algorithm

   ArraySort(symbols,deals,new CSelectionSort<string,ulong>,false);

//--- check the result of sorting by printing a table of symbols. 

//your table will look different

   DealsPrint(deals);

  }

//--------------------------------------------------------------------

//                          deal | symbol

//--------------------------------------------------------------------

//                     170477949 | XAUUSD

//                     170764903 | XAUUSD

//                     170764902 | XAUUSD

//                     170252156 | XAUUSD

//                     170541532 | XAUUSD

//                     172313700 | BTCUSD

//                     172313699 | BTCUSD

//                     172313666 | BTCUSD

//                     172313530 | BTCUSD

//                     172313512 | BTCUSD

//                     172313511 | BTCUSD

//                     172313502 | BTCUSD

//                     172313501 | BTCUSD

//                     172313500 | BTCUSD

//                     172313493 | BTCUSD

//                     172313490 | BTCUSD

//                     172313488 | BTCUSD

//                     172313474 | BTCUSD

//                     172313453 | BTCUSD

//                     172313412 | BTCUSD

//                     171147845 | BTCUSD

//                     171145409 | BTCUSD

//                     171145256 | BTCUSD

//                     171145029 | BTCUSD

//                     171011667 | BTCUSD

//                     170983807 | BTCUSD

//                     170720576 | BTCUSD

//                     170429897 | BTCUSD

//                     169998112 | BTCUSD

//                     169998099 | BTCUSD

//                     169990154 | BTCUSD

//--------------------------------------------------------------------

Comments