mt4函数和编程必备(8)

2020-04-14 06:25

}

double FileReadNumber( int handle) 从文件中读取数字,只能在CSV里使用

:: 输入参数

handle - FileOpen()返回的句柄

示例:

int handle; int value; handle=FileOpen(\, ';'); if(handle>0) { value=FileReadNumber(handle); FileClose(handle); }

string FileReadString( int handle, int length=0) 从文件中读取字符串

:: 输入参数

handle - FileOpen()返回的句柄 length - 读取字符串长度

示例:

int handle; string str; handle=FileOpen(\if(handle>0) { str=FileReadString(handle); FileClose(handle); }

bool FileSeek( int handle, int offset, int origin) 移动指针移动到某一点,如果成功返回true

:: 输入参数

handle - FileOpen()返回的句柄 offset - 设置的原点

origin - SEEK_CUR从当前位置开始 SEEK_SET从文件头部开始 SEEK_END 从文件尾部开始

示例:

int handle=FileOpen(\if(handle>0) { FileSeek(handle, 10, SEEK_SET); FileReadInteger(handle); FileClose(handle); handle=0; }

int FileSize( int handle) 返回文件大小

:: 输入参数

handle - FileOpen()返回的句柄

示例:

int handle; int size; handle=FileOpen(\if(handle>0) { size=FileSize(handle); Print(\FileClose(handle); }

int FileTell( int handle) 返回文件读写指针当前的位置

:: 输入参数

handle - FileOpen()返回的句柄

示例:

int handle; int pos; handle=FileOpen(\// reading some data pos=FileTell(handle); Print(\

int FileWrite( int handle, ... ) 向文件写入数据

:: 输入参数

handle - FileOpen()返回的句柄 ... - 写入的数据

示例:

int handle; datetime orderOpen=OrderOpenTime(); handle=FileOpen(\if(handle>0) { FileWrite(handle, Close[0], Open[0], High[0], Low[0], TimeToStr(orderOpen)); FileClose(handle); }

int FileWriteArray( int handle, object array[], int start, int count) 向文件写入数组

:: 输入参数

handle - FileOpen()返回的句柄 array[] - 要写入的数组 start - 写入的开始点 count - 写入的项目数

示例:

int handle; double BarOpenValues[10]; // copy first ten bars to the array for(int i=0;i<10; i++) BarOpenValues[i]=Open[i]; // writing array to the file handle=FileOpen(\if(handle>0) { FileWriteArray(handle, BarOpenValues, 3, 7); // writing last 7 elements FileClose(handle); }

int FileWriteDouble( int handle, double value, int size=DOUBLE_VALUE) 向文件写入浮点型数据

:: 输入参数

handle - FileOpen()返回的句柄 value - 要写入的值

size - 写入的格式,DOUBLE_VALUE (8 bytes, default)或FLOAT_VALUE (4 bytes).

示例:

int handle; double var1=0.345; handle=FileOpen(\if(handle<1) { Print(\return(0); } FileWriteDouble(h1, var1, DOUBLE_VALUE); //... FileClose(handle);

int FileWriteInteger( int handle, int value, int size=LONG_VALUE) 向文件写入整型数据

:: 输入参数

handle - FileOpen()返回的句柄 value - 要写入的值

size - 写入的格式,CHAR_VALUE (1 byte),SHORT_VALUE (2 bytes),LONG_VALUE (4 bytes, default).

示例:

int handle; int value=10; handle=FileOpen(\if(handle<1) { Print(\return(0); } FileWriteInteger(handle, value, SHORT_VALUE); //... FileClose(handle);

int FileWriteString( int handle, string value, int length) 向文件写入字符串数据

:: 输入参数

handle - FileOpen()返回的句柄 value - 要写入的值 length - 写入的字符长度

示例:

int handle; string str=\handle=FileOpen(\if(handle<1) { Print(\return(0); } FileWriteString(h1, str, 8); FileClose(handle); 全局变量函数 [Global Variables Functions]

bool GlobalVariableCheck( string name) 检查全局变量是否存在

:: 输入参数

name - 全局变量的名称

示例:

// check variable before use if(!GlobalVariableCheck(\GlobalVariableSet(\

bool GlobalVariableDel( string name) 删除全局变量

:: 输入参数

name - 全局变量的名称

示例:

// deleting global variable with name \GlobalVariableDel(\

double GlobalVariableGet( string name) 获取全局变量的值

:: 输入参数

name - 全局变量的名称

示例:

double v1=GlobalVariableGet(\//---- check function call result if(GetLastError()!=0) return(false); //---- continue processing

double GlobalVariableGet( string name) 获取全局变量的值

:: 输入参数

name - 全局变量的名称

示例:

double v1=GlobalVariableGet(\//---- check function call result if(GetLastError()!=0) return(false); //---- continue processing

datetime GlobalVariableSet( string name, double value ) 设置全局变量的值

:: 输入参数

name - 全局变量的名称 value - 全局变量的值

示例:

//---- try to set new value if(GlobalVariableSet(\return(false); //---- continue processing

bool GlobalVariableSetOnCondition( string name, double value, double check_value)


mt4函数和编程必备(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:江苏省机关第六届万人学法知识竞赛 网上答题试卷4

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: