본문 바로가기
트레이딩/메타트레이더 코딩

MQL5. Arrays. 배열

by i.got.it 2019. 5. 17.

 

 

 

 

MQL5 에서 정적 배열  

- 일반 C와 동일. 

// MQL5 에서 정적 배열. 일반 C 문법과 동일. 

double myData[100];  

 

MQL5 에서 동적배열. 

- 일반 C와 다르며,  사용 편리. 

// MQL5 Dnamic array 

double myData[]; // 배열 크기 기록없이 선언하면 동적배열이됨. 

ArrayResize(myData, 99); // 사용하기 전에 배열 크기 지정함수 호출해서 설정. 
ArrayResize(myData, 15); // 앞에서 설정된 99를 15로 줄인것.
ArrayResize(myData, 0); // 앞에서 설정된 15를 0로 줄인것.
ArrayFree(myData); // myData 해제하는것. ArrayResize(myData, 0); 과동일 효과. 


bool retv=ArrayIsDynamic(myData); // dynamic 이면 1리턴, static 이면 0리턴. 

////// 배열을 함수 인자로 전달하기. 

void Func(double &myData[]); // 함수 선언. 

Func(mydata); // Func 콜 하면서 배열 myData 전달 

 

 

 

MQL5 Array 관련함수 전체.

 

Arrays are allowed to be maximum four-dimensional. Each dimension is indexed from 0 to dimension_size-1. In a particular case of a one-dimensional array of 50 elements, calling of the first element will appear as array[0], of the last one - as array[49].

Function

Action

ArrayBsearch

Returns index of the first found element in the first array dimension

ArrayCopy

Copies one array into another

ArrayCompare

Returns the result of comparing two arrays of simple types or custom structures without complex objects

ArrayFree

Frees up buffer of any dynamic array and sets the size of the zero dimension in 0.

ArrayGetAsSeries

Checks direction of array indexing

ArrayInitialize

Sets all elements of a numeric array into a single value

ArrayFill

Fills an array with the specified value

ArrayIsSeries

Checks whether an array is a timeseries

ArrayIsDynamic

Checks whether an array is dynamic

ArrayMaximum

Search for an element with the maximal value

ArrayMinimum

Search for an element with the minimal value

ArrayPrint

Prints an array of a simple type or a simple structure into journal

ArrayRange

Returns the number of elements in the specified dimension of the array

ArrayResize

Sets the new size in the first dimension of the array

ArrayInsert

Inserts the specified number of elements from a source array to a receiving one starting from a specified index

ArrayRemove

Removes the specified number of elements from the array starting with a specified index

ArrayReverse

Reverses the specified number of elements in the array starting with a specified index

ArraySetAsSeries

Sets the direction of array indexing

ArraySize

Returns the number of elements in the array

ArraySort

Sorting of numeric arrays by the first dimension

ArraySwap

Swaps the contents of two dynamic arrays of the same type

 

 

 

상세 설명.

https://www.mql5.com/en/articles/567

 

MQL5 Programming Basics: Arrays

Arrays are an integral part of almost any programming language along with variables and functions. The article should be of interest primarily to novice MQL5 programmers, while experienced programmers will have a good opportunity to summarize and systemati

www.mql5.com

 

 


첫등록 : 2019년 5월 17일 

최종수정 : 

 

본 글 단축주소 : https://igotit.tistory.com/2175

 


 

댓글



 

비트코인




암호화폐       외환/나스닥/골드         암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)         프랍 트레이더 온라인 지원가능. MT4,MT5