Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Example of sorting structure array in ascending order of fields - MetaTrader 5 script | Trading script download - MT4/MT5 resources

author EAcpu | 4 reads | 0 comments |

Ascending Sort A Struct Array By A Field Example - script for MetaTrader 5

Here is an example of sorting a list of structures by field in ascending order. You can understand and customize the above algorithm according to the purpose of use. This is the most basic example and a direction for solving the arrangement in the array structure.

The algorithms used in this example are quick sort and merge sort.

  ps list_[ 0 ] = ExStruct( 1.0 ,D '2025.08.06 10:00' );
  ps list_[ 1 ] = ExStruct( 2.0 ,D '2025.08.04 09:00' );
  ps list_[ 2 ] = ExStruct( 3.0 ,D '2025.08.05 12:00' );
  ps list_[ 3 ] = ExStruct( 4.0 ,D '2025.08.07 14:00' );
  ps list_[ 4 ] = ExStruct( 5.0 ,D '2025.08.03 02:00' );

output

Ascending Sort A Struct Array By A Field Example - script for MetaTrader 5


Attachment download

📎 structsort.mq5 (3.68 KB)

Source: MQL5 #62366

Verification code Refresh