Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Join our fan page
You liked the script? Try it in the MetaTrader 5 terminal
- Views:
- 3486
- Rating:
- Published:
- 2021.02.03 06:41
-
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance
//+------------------------------------------------------------------+ //| GnomeSort.mq5 | //| 2019-2021, dimitri pecheritsa | //| mql5.com/en/users/dmipec | //|------------------------------------------------------------------| //| c | gnome sort | //|------------------------------------------------------------------| //| use | array sorting algorithm | //| best: n; average: n^2; worst: n^2 | //| memory: 1; stable: yes; method: exchanging | //| note: tiny code size | //| originally proposed by iranian computer scientist hamid | //|sarbazi-azad (professor of computer science and engineering at | //|sharif university of technology) in 2000. the sort was first | //|called stupid sort (not to be confused with bogosort), and then | //|later described by dick grune and named gnome sort. | //| the gnome sort is a sorting algorithm which is similar to | //|insertion sort in that it works with one item at a time but gets | //|the item to the proper place by a series of swaps, similar to a | //|bubble sort. it is conceptually simple, requiring no nested loops.| //|the average running time is o(n^2) but tends towards o(n) if the | //|list is initially almost sorted. | //| the algorithm finds the first place where two adjacent elements | //|are in the wrong order and swaps them. it takes advantage of the | //|fact that performing a swap can introduce a new out-of-order | //|adjacent pair next to the previously swapped elements. it does not| //|assume that elements forward of the current position are sorted, | //|so it only needs to check the position directly previous to the | //|swapped elements. | //|------------------------------------------------------------------| //| 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 //--------------------------------------------------------------------
![INDICATOR Breakout Strength Meter - MT5](https://c.mql5.com/i/code/indicator.png)
The breakout strength meter is a trading tool that is used to identify which currencies are the strongest to breakout, and which currencies are the weakest to breakout
![Spread data collector](https://c.mql5.com/i/code/expert.png)
This EA collects information about the spreads and Shows the number of spreads in the specified range based on the ticks that occur each year.
![introsort - array sorting algorithm](https://c.mql5.com/i/code/library.png)
hybrid sorting algorithm that provides both fast average performance and (asymptotically) optimal worst-case performance
![Currency Strenght Meter - MT5](https://c.mql5.com/i/code/script.png)
The currency strength meter is a trading tool that is used to identify trending and consolidating markets based on the percentage rate of change in price from one period to the next.