거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

quick sort - sorting algorithm - MetaTrader 5용 라이브러리

조회수:
3620
평가:
(13)
게시됨:
2020.12.23 09:36
QuickSort.mq5 (7.04 KB) 조회
\MQL5\Include\Mqh\Algorithms\QuickSort\
QuickSort.mqh (3.35 KB) 조회
Functions.mqh (2.29 KB) 조회
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
//+------------------------------------------------------------------+
//|                                                    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[];
   PositionsLoad(tickets,symbol);
//---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 Classic Moving Averages with colors

    The indicator displays a colored moving average.

    Basic Martingale EA v2 Basic Martingale EA v2

    A Sample of Averaging Up/Down Martingale EA.

    Free mt5 Copier 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 EA Fibonacci Potential Entry - MT5

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