Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal

# quick sort - sorting algorithm - library for MetaTrader 5

Views:
599
Rating:
Published:
2020.12.23 09:36
```//+------------------------------------------------------------------+
//|                                                    QuickSort.mq5 |
//|                                    2019-2020, dimitri pecheritsa |
//|                                                 792112@gmail.com |
//+------------------------------------------------------------------+
//
//   quick sort - sorting algorithm
//
//   quick sort is a highly efficient sorting algorithm and is based
//on partitioning of array of data into smaller arrays
//   a large array is partitioned into two arrays one of which holds
//values smaller than the specified value say pivot, based on which
//the partition is made and another array holds values greater than
//the pivot value
//   quick sort partitions an array and then calls itself recursively
//twice to sort the two resulting subarrays
//   this algorithm is quite efficient for large-sized data sets as
//its average and worst-case complexity are O(nlogn) and theta(n^2),
//respectively
//
//   quick sort pivot algorithm
//
//   step 1: choose the highest index value has pivot
//   step 2: take two variables to point left and right of the values
//excluding pivot
//   step 3: left points to the low index
//   step 4: right points to the high
//   step 5: while value at left is less than pivot move right
//   step 6: while value at right is greater than pivot move left
//   step 7: if both step 5 and step 6 does not match swap left and
//right
//   step 8: if left ≥ right, the point where they met is new pivot
//
//   quick sort algorithm
//
//   using pivot algorithm recursively, we end up with smaller
//possible partitions
//   each partition is then processed for quick sort
//   step 1: make the right-most index value pivot
//   step 2: partition the array using pivot value
//   step 3: quicksort left partition recursively
//   step 4: quicksort right partition recursively
//
//+------------------------------------------------------------------+
//| quick sort example - sort positions by open price in accending   |
//| or descending order                                              |
//+------------------------------------------------------------------+
#include <Mqh\Algorithms\QuickSort\QuickSort.mqh>
#include <Mqh\Algorithms\QuickSort\Functions.mqh>
void OnStart()
{
//---load tickets from terminal - the items to be sorted
string symbol=_Symbol;
ulong tickets[];
//---create keys for sorting - open prices of the positions
double keys[];
PositionsKeysPriceOpen(tickets,keys);
//---sort positions by open price
CQuickSort<double,ulong> sorter;
bool accending_order=true; //false for descending
sorter.Sort(keys,tickets,accending_order);
//---print positions
int digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
PositionsPrint(tickets,digits);
}
//
//   example output
//
//    EURUSD | 195762889 |  1.16667
//    EURUSD | 195806889 |  1.16939
//    EURUSD | 195998318 |  1.17384
//    EURUSD | 197300364 |  1.17602
//    EURUSD | 197454338 |  1.17680
//    EURUSD | 197488771 |  1.17859
//    EURUSD | 196985503 |  1.17924
//    EURUSD | 196058650 |  1.17935
//    EURUSD | 197513038 |  1.18068
//    EURUSD | 196921898 |  1.18179
//    EURUSD | 196317657 |  1.18295
//    EURUSD | 198719928 |  1.18325
//    EURUSD | 198678762 |  1.18342
//    EURUSD | 198673400 |  1.18387
//    EURUSD | 197932787 |  1.18482
//   ...
//
//+------------------------------------------------------------------+
```
Classic Moving Averages with colors

The indicator displays a colored moving average.

Basic Martingale EA

A Sample of Averaging Up/Down Martingale EA.

Free mt5 Copier

Copy trading has become such a critical feature of forex trading. Some people see this as a potential business opportunity, while for opensource die-hards like me, we believe in giving back to the community rather than putting a price tag on everything 'nice'. So here it comes. A free opensource trade copier, which you are freely allowed to modify and distribute according to MIT license terms. It still has limited features, but the essentials like lot normalization are there. Please note that this copier only works for trading terminals installed on the same machine. Please share back any upgrades, enhancements or bug fixes to the discussion. Enjoy!

EA Fibonacci Potential Entry - MT5

The 8 effective steps to build a robust day trading plan using Fibonacci retracement