-
-
Save WinstonN/d1fa1fb7090048c836981fae459f5435 to your computer and use it in GitHub Desktop.
Array utility functions for MetaTrader 4. Helpful functions for doing some of the repetitive tasks in MQL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * clearArray | |
| * This function deletes all items in array (sets it to EMPTY_VALUE) and resizes array according to size (default = 1). | |
| * @param int& theArray - passing the array by reference | |
| * @param int size - size of the array (default = 1) | |
| * @return int blank array of size | |
| */ | |
| int clearArray( int& theArray[], int size = 1 ) { | |
| ArrayResize( theArray, size ); | |
| ArrayInitialize( theArray, EMPTY_VALUE ); | |
| return( theArray ); | |
| } | |
| /* | |
| * addToArray | |
| * This function appends an integer value to an integer array. | |
| * @param int& theArray - passing the array by reference | |
| * @param int val - the item to be appended (no checks on val) | |
| * @return int the array with appended value | |
| */ | |
| int addToArray( int& theArray[], int val ) { | |
| ArrayResize( theArray, ArraySize( theArray ) + 1 ); | |
| theArray[ ArraySize( theArray ) - 1 ] = val; | |
| return( theArray ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment