,欢迎光临!
加入收藏设为首页在线咨询
您当前位置:网站首页 >> 投资软件 >> MT4/MT5 >> MT4-MQL4 编程入门(第15节 数学运算函数)

MT4-MQL4 编程入门(第15节 数学运算函数)

2010-12-27 14:37:23 来源:《008财富网》 浏览:24674

免费QQ群号94337889( 外盘期货/恒指期货交流)

第十五节 数学运算函数 [Math & Trig]

 

 double MathAbs( double value) 返回数字的绝对值 :: 输入参数 value - 要处理的数字 示例: double dx=-3.141593, dy; // calc MathAbs dy=MathAbs(dx); Print("The absolute value of ",dx," is ",dy); // Output: The absolute value of -3.141593 is 3.141593

 

double MathArccos( double x) 计算反余弦值 :: 输入参数 value - 要处理的数字,范围-11 示例: double x=0.32696, y; y=asin(x); Print("Arcsine of ",x," = ",y); y=acos(x); Print("Arccosine of ",x," = ",y); //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("Arcsine of ",x," = ",y); y=acos(x); Print("Arccosine of ",x," = ",y); //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("Arctangent of ",x," is ",y); //Output: Arctangent of -862.42 is -1.5696

 

double MathCeil( double x) 返回向前进位后的值 :: 输入参数 x - 要处理的值 示例: double y; y=MathCeil(2.8); Print("The ceil of 2.8 is ",y); y=MathCeil(-2.8); Print("The ceil of -2.8 is ",y); /*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("MathSin(",x,") = ",y); y=MathCos(x); Print("MathCos(",x,") = ",y); //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("MathExp(",x,") = ",y); //Output: MathExp(2.3026)=10

 

double MathFloor( double x) 返回向后进位后的值 :: 输入参数 x - 要处理的值 示例: double y; y=MathFloor(2.8); Print("The floor of 2.8 is ",y); y=MathFloor(-2.8); Print("The floor of -2.8 is ",y); /*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("MathLog(",x,") = ", y); //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("The remainder of ",x," / ",y," is ",z); //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," to the power of ",y," is ", z); //Output: 2 to the power of 3 is 8

int MathRand( ) 取随机数 示例: MathSrand(LocalTime()); // Display 10 numbers. for(int i=0;i<10;i++ ) Print("random value ", MathRand());

 

double MathRound( double value) 取四舍五入的值 :: 输入参数 value - 要处理的值 示例: double y=MathRound(2.8); Print("The round of 2.8 is ",y); y=MathRound(2.4); Print("The round of -2.4 is ",y); //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; x=pi/2; y=MathSin(x); Print("MathSin(",x,") = ",y); y=MathCos(x); Print("MathCos(",x,") = ",y); //Output: MathSin(1.5708)=1 // MathCos(1.5708)=0

 

double MathSqrt( double x) 计算平方根 :: 输入参数 x - 要处理的值 示例: double question=45.35, answer; answer=MathSqrt(question); if(question<0) Print("Error: MathSqrt returns ",answer," answer"); else Print("The square root of ",question," is ", answer); //Output: The square root of 45.35 is 6.73

 

void MathSrand( int seed) 通过Seed产生随机数 :: 输入参数 seed - 随机数的种子 示例: MathSrand(LocalTime()); // Display 10 numbers. for(int i=0;i<10;i++ ) Print("random value ", MathRand());

 

 double MathTan( double x) 计算正切值 :: 输入参数 x - 要计算的角度 示例: double pi=3.1415926535; double x,y; x=MathTan(pi/4); Print("MathTan(",pi/4," = ",x); //Output: MathTan(0.7856)=1

发表评论
网名:
评论:
验证:
共有0人对本文发表评论查看所有评论(网友评论仅供表达个人看法,并不表明本站同意其观点或证实其描述)
  • 联系邮箱:service#918008.com(请把#换成@) - 在线QQ:77446881
  • 外盘期货|外盘开户|恒指期货|恒指期货期权开户|外盘期货开户|外盘期权开户|新华富时A50指数开户|恒指开户|恒指配资|恒指软件|
  • 外盘配资|外盘期货配资|外汇软件|恒指期权开户|美原油软件|恒指喊单软件|期货配资|恒指分析软件
  • 苏ICP备17053501号 Copyright 2018, 版权所有 www.918008.com.
在线客服 客服软件
在线客服系统

免责申明:本网站刊载的内容,部份搜集自网络,供大家免费浏览,所有相关权益归原作者所有,《008财富网》无意侵犯任何人、任何机构的权益!如果其中有您的文章不想被我们转载,请告诉我们!本网站刊载的所有内容,不构成投资建议,仅供参考,风险自负。任何投机交易在具体高度收益性的同时也具有高度风险性,通常只适合于能够承担相应风险的人士。鉴于存在的这些风险,您应该在完全了解所涉及交易的性质以及自身面临风险的程度后才进行交易。投资有风险,入市须谨慎!所有解释权归《008财富网》所有。