Watch how to download trading robots for free
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Libraries

selection sort - array sorting algorithm - library for MetaTrader 5

DMITRII PECHERITSA

Views:
364
Rating:
Published:
2021.01.20 06:48
\MQL5\Include\Mqh\Algorithms\SelectionSort\ \MQL5\Include\Mqh\Algorithms\ \MQL5\Include\Mqh\Universal\
//+------------------------------------------------------------------+
//|                                                SelectionSort.mq5 |
//|                                    2019-2021, dimitri pecheritsa |
//|                                         mql5.com/en/users/dmipec |
//+------------------------------------------------------------------+
//| selection sort - array sorting algorithm                         |
//+------------------------------------------------------------------+
//|  best: n^2, average: n^2, worst: n^2                             |
//|  memory: 1, stable: no, method: selection                        |
//|  note: stable with o(n) extra space or when using linked lists.  |
//+------------------------------------------------------------------+
//|  in computer science, selection sort is an in-place comparison   |
//|sorting algorithm. it has an o(n2) time complexity, which makes   |
//|it inefficient on large lists, and generally performs worse than  |
//|the similar insertion sort. selection sort is noted for its       |
//|simplicity and has performance advantages over more complicated   |
//|algorithms in certain situations, particularly where auxiliary    |
//|memory is limited.                                                |
//|  the time efficiency of selection sort is quadratic, so there    |
//|are a number of sorting techniques which have better time         |
//|complexity than selection sort. one thing which distinguishes     |
//|selection sort from other sorting algorithms is that it makes the |
//|minimum possible number of swaps, n − 1 in the worst case.        |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| 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
//--------------------------------------------------------------------


NoiseEliminationTechnology NoiseEliminationTechnology

Published by John Ehlers in "Stocks & Commodities Dec. 2020" (16-18).

MQLUnit - Tiny Unit Tests Framework For Complex Expert Advisors MQLUnit - Tiny Unit Tests Framework For Complex Expert Advisors

This unit test frameworks eases the development of unit tests for more complex expert advisor programs. The MQL5 developer can test single components. The test framework starts the strategy tester so that there is test data available if required. I am using the framework to do test driven development (TDD) on my MQL5 programs.

Spread Informer Spread Informer

This EA collects information about the spread and shows the statistics on the chart. When the EA ends its working, it prints all statistics to the Journal, which can be useful for the Strategy Tester.

Log4mql(mini) MT5 Log4mql(mini) MT5

A light header-only version of Log4mql that provides standardized logging.