《mq4编程语言举例》由会员分享,可在线阅读,更多相关《mq4编程语言举例(82页珍藏版)》请在金锄头文库上搜索。
1、1Account InformationAccountBalance()AccountCredit()AccountCurrency()AccountEquity()AccountFreeMargin()AccountLeverage()AccountMargin()AccountName()AccountNumber()AccountProfit()double AccountBalance()Returns currently selected accounts balance value. Sampledouble balance;balance=AccountBalance();dou
2、ble AccountCredit()Returns currently selected accounts credit value. Sampledouble credit;credit=AccountCredit();Print(“account number “, credit);string AccountCurrency()Returns currently selected accounts currency name. SamplePrint(“account currency is “, AccountCurrency();double AccountEquity()Retu
3、rns currently selected accounts equity value. Sampledouble equity;equity=AccountEquity();2double AccountFreeMargin()Returns currently selected accounts free margin value. Sampledouble margin;margin=AccountFreeMargin();int AccountLeverage()Returns currently selected accounts leverage. SamplePrint(“Ac
4、count “,AccountNumber(), “ leverage is “, AccountLeverage();double AccountMargin()Returns currently selected accounts margin value. Sampledouble margin;margin=AccountMargin();Print(“account margin “, margin);string AccountName()Returns currently selected accounts name. SamplePrint(“account name “, A
5、ccountName();int AccountNumber()Returns currently selected accounts number. SamplePrint(“account number “, AccountNumber();double AccountProfit()Returns currently selected accounts profit value. Sampledouble profit;3profit=AccountProfit();Array functionsArrayBsearch()ArrayCopy()ArrayCopyRates()Array
6、CopySeries()ArrayDimension()ArrayGetAsSeries()ArrayIsSeries()ArrayMaximum()ArrayMinimum()ArrayRange()ArrayResize()ArraySetAsSeries()ArraySize()ArraySort()int ArrayBsearch(double array,double value,int count=WHOLE_ARRAY,int start=0,int direction=MODE_ASCEND)Returns a index to the first occurrence of
7、value in the first dimension of specified array if found or nearest if it isnt.The function cant be used with string arrays and serial numeric arrays.Note: Binary search processes sorted arrays only. To sort numeric arrays use ArraySort() functions. Parametersarray - The numeric array to search.valu
8、e - The value to search for.count - Elements count to search. By default search in the whole array.start - Starting index to search. By default search starts from first element.direction - Search direction. It can be any one of the following values:MODE_ASCEND searhing in forward direction,MODE_DESC
9、END searching in backward direction.Sampledouble opens_array20;int idx;for(int i=0;iOptions-EMail tab if enabled.Parameterssubject - subject text.some_text - mail body.Sampledouble lastclose=Close0;if(lastclose0) counted_bars-;limit=Bars-counted_bars;/- main loopfor(int i=0; i= 12 | Hour() 0)/ worki
10、ng with file .FileClose(handle);25void FileDelete(string filename)Removes specified file name.Note: Files can be deleted only from terminal_direxpertsfiles directory and its subdirectories. The root directory for file operations is terminal_direxpertsfiles directory. Parametersfilename - Path to the
11、 file.Sample/ file my_table.csv will be deleted from terminal_direxpertsfiles directoryFileDelete(“my_table.csv“);void FileFlush(int handle)Flushes all data stored in the file buffer to disk.Parametershandle - File handle.Sampleint bars_count=Bars;int handle=FileOpen(“mydat.csv“,FILE_CSV|FILE_WRITE)
12、;if(handle 0)FileWrite(handle, “#“,“OPEN“,“CLOSE“,“HIGH“,“LOW“);for(int i=0;i 0)FileReadArray(handle, varray, 0, 10);FileClose(handle);double FileReadDouble(int handle,int size=DOUBLE_VALUE)Reads the number from binary files from the current file position. Number format size can be 8 bytes (double),
13、 or 4 bytes (float) length. If format size is not specified system attempt to read 8 bytes length (double) value. Parametershandle - File handle, returned by FileOpen() functionsize - Number format size. can be DOUBLE_VALUE(8 bytes) or FLOAT_VALUE(4 bytes).Sampleint handle;double value;handle = File
14、Open(“mydata.dat“,FILE_BIN);if(handle 0)value=FileReadDouble(handle,DOUBLE_VALUE);FileClose(handle);28int FileReadInteger(int handle,int size=LONG_VALUE)Read the integer from binary files from the current file position. Integer format size can be 1, 2 or 4 bytes length. If format size is not specifi
15、ed system attempt to read 4 bytes length value. Parametershandle - file handle, returned by FileOpen() functionsize - Format size. Can be CHAR_VALUE(1 byte), SHORT_VALUE(2 bytes) or LONG_VALUE(4 bytes).Sampleint handle;int value;handle=FileOpen(“mydata.dat“, FILE_BIN|FILE_READ);if(handle0)value=File
16、ReadInteger(h1,2);FileClose(handle);double FileReadNumber(int handle)Read the number from the current file position to the delimiter. Only for CSV files.Parametershandle - file handle, returned by FileOpen() functionSampleint handle;int value;handle = FileOpen(“filename.csv“, FILE_CSV, “t“);if(handle 0)value = FileReadNumber(handle);FileClose(handle);string FileReadString(int handle,int length=0)Read