mt4函数和编程必备(5)

2020-04-14 06:25

有条件的设置全局变量的值

:: 输入参数

name - 全局变量的名称 value - 全局变量的值 check_value - 检查变量的值

示例:

int init() { //---- create global variable GlobalVariableSet(\//... } int start() { //---- try to lock common resource while(!IsStopped()) { //---- locking if(GlobalVariableSetOnCondition(\//---- may be variable deleted? if(GetLastError()==ERR_GLOBAL_VARIABLE_NOT_FOUND) return(0); //---- sleeping Sleep(500); } //---- resource locked // ... do some work //---- unlock resource GlobalVariableSet(\}

void GlobalVariablesDeleteAll( ) 删除所有全局变量 示例:

GlobalVariablesDeleteAll(); 数学运算函数 [Math & Trig]

double MathAbs( double value) 返回数字的绝对值

:: 输入参数

value - 要处理的数字

示例:

double dx=-3.141593, dy; // calc MathAbs dy=MathAbs(dx); Print(\// Output: The absolute value of -3.141593 is 3.141593

double MathArccos( double x) 计算反余弦值

:: 输入参数

value - 要处理的数字,范围-1到1

示例:

double x=0.32696, y; y=asin(x); Print(\y=acos(x); Print(\//Output: Arcsine of 0.326960=0.333085 //Output: Arccosine of 0.326960=1.237711

double MathArcsin( double x) 计算反正弦值

:: 输入参数 x - 要处理的值

示例:

double x=0.32696, y; y=MathArcsin(x); Print(\y=acos(x); Print(\//Output: Arcsine of 0.326960=0.333085 //Output: Arccosine of 0.326960=1.237711

double MathArctan( double x) 计算反正切值

:: 输入参数 x - 要处理的值

示例:

double x=-862.42, y; y=MathArctan(x); Print(\//Output: Arctangent of -862.42 is -1.5696

double MathCeil( double x) 返回向前进位后的值

:: 输入参数 x - 要处理的值

示例:

double y; y=MathCeil(2.8); Print(\y=MathCeil(-2.8); Print(\/*Output: The ceil of 2.8 is 3 The ceil of -2.8 is -2*/

double MathCos( double value) 计算余弦值

:: 输入参数

value - 要处理的值

示例:

double pi=3.1415926535; double x, y; x=pi/2; y=MathSin(x); Print(\y=MathCos(x); Print(\//Output: MathSin(1.5708)=1 // MathCos(1.5708)=0

double MathExp( double d)

Returns value the number e raised to the power d. On overflow, the function returns INF (infinite) and on underflow, MathExp returns 0.

:: 输入参数

d - A number specifying a power.

示例:

double x=2.302585093,y; y=MathExp(x); Print(\//Output: MathExp(2.3026)=10

double MathFloor( double x) 返回向后进位后的值

:: 输入参数 x - 要处理的值

示例:

double y; y=MathFloor(2.8); Print(\y=MathFloor(-2.8); Print(\/*Output: The floor of 2.8 is 2 The floor of -2.8 is -3*/

double MathLog( double x) 计算对数

:: 输入参数 x - 要处理的值

示例:

double x=9000.0,y; y=MathLog(x); Print(\//Output: MathLog(9000)=9.10498

double MathMax( double value1, double value2) 计算两个值中的最大值

:: 输入参数 value1 - 第一个值 value2 - 第二个值

示例:

double result=MathMax(1.08,Bid);

double MathMin( double value1, double value2) 计算两个值中的最小值

:: 输入参数 value1 - 第一个值 value2 - 第二个值

示例:

double result=MathMin(1.08,Ask);

double MathMod( double value, double value2) 计算两个值相除的余数

:: 输入参数 value - 被除数 value2 - 除数

示例:

double x=-10.0,y=3.0,z; z=MathMod(x,y); Print(\//Output: The remainder of -10 / 3 is -1

double MathPow( double base, double exponent) 计算指数

:: 输入参数 base - 基数 exponent - 指数

示例:

double x=2.0,y=3.0,z; z=MathPow(x,y); Printf(x,\//Output: 2 to the power of 3 is 8

int MathRand( ) 取随机数 示例:

MathSrand(LocalTime()); // Display 10 numbers. for(int i=0;i<10;i++ ) Print(\

double MathRound( double value) 取四舍五入的值

:: 输入参数

value - 要处理的值

示例:

double y=MathRound(2.8); Print(\y=MathRound(2.4); Print(\//Output: The round of 2.8 is 3 // The round of -2.4 is -2

double MathSin( double value) 计算正弦数

:: 输入参数

value - 要处理的值

示例:

double pi=3.1415926535; double x, y;


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

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

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

马上注册会员

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