init 初始化函数;加载函数。deinit卸载函数。
start为主函数,主要执行代码在这里。
init主要存放图,指标的基本初始化,包括曲线规模,标记,指标显示格式。
start是循环运行的。
数组函数常用的例子;
mt4编程大全
// 单行注释
/* 多行
注释 // 嵌套的单行注释
注释结束 */
[if !supportLists]· [endif]Integer (int)
[if !supportLists]· [endif]Boolean (bool)
[if !supportLists]· [endif]ëèòåðàëû (char)
[if !supportLists]· [endif]String (string)
[if !supportLists]· [endif]Floating-point number (double)
[if !supportLists]· [endif]Color (color)
[if !supportLists]· [endif]Datetime (datetime)
bool a = true;
bool b = false;
bool c = 1;
"This is a character string"
"Copyright symbol \t\xA9"
"this line with LF symbol \n"
"A" "1234567890" "0" "$"
将x的值赋值给y y = x;
将x的值加到y上面 y += x;
在y上面减去x的值 y -= x;
得到y的x倍的值 y *= x;
得到y除以x的值 y /= x;
取y除以x后的余数 y %= x;
y向右位移x位 y >>= x;
y向左位移x位 y <<= x;
得到逻辑AND的值 y &= x;
得到逻辑OR的值 y |= x;
得到逻辑非OR的值 y ^= x;
// symbol constants
C'128,128,128' // gray
C'0x00,0x00,0xFF' // blue
// named color
Red
Yellow
Black
// integer-valued representation
0xFFFFFF // white
16777215 // white
0x008000 // green
32768 // green
~ 运算符对操作数执行按位求补操作。
b = ~n;
>> 运算符对操作数执行向右位移操作。
x = x >> y;
<< 运算符对操作数执行向左位移操作。
x = x << y;
一元 & 运算符返回操作数的地址
为整型和bool 类型预定义了二进制 & 运算符。对于整型,& 计算操作数的按位“与”。对于 bool 操作数,& 计算操作数的逻辑“与”;也就是说,当且仅当两个操作数均为 true 时,其结果才为 true。
b = ((x & y) != 0);
二进制| 运算符是为整型和 bool 类型预定义的。对于整型,| 对操作数进行按位“或”运算。对于 bool 操作数,| 对操作数进行逻辑“或”计算,也就是说,当且仅当两个操作数均为 false 时,其结果才为 false。
b = x | y;
为整型和bool 类型预定义了 ^ 二进制操作数。对于整型,^ 计算操作数的按位“异或”。对于 bool 操作数,^ 计算操作数的逻辑“异或”;也就是说,当且仅当只有一个操作数为 true 时,其结果才为 true。
b = x ^ y;
注:位逻辑运算符只作用于Integers类型
if while for
init()在载入时调用,可以用此函数在开始自定义指标或者自动交易之前做初始化操作。
deinit()在卸载时调用,可以用此函数在去处自定义指标或者自动交易之前做初始化操作。
start()当数据变动时触发,对于自定义指标或者自动交易的编程主要依靠此函数进行。
函数:
int somefunc()
{
double a=linfunc(0.3, 10.5, 8);
}
double linfunc(double x, double a, double b)
{
return (a*x + b);
}
extern datetime tBegin_Data = D'2004.01.01 00:00';
extern color cModify_Color = C'0x44,0xB9,0xE6';
#define ABC 100
#define PI 0.314
#define COMPANY_NAME "MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property copyright "MetaQuotes Software Corp."
#property stacksize 1024














void IndicatorBuffers(int count)
设置自定义指标缓存数
:: 输入参数
count - 缓存数量
void IndicatorShortName( string name)
设置指标的简称
:: 输入参数
name - 新的简称
bool SetIndexBuffer( int index, double array[])
设置指标线的缓存数组
:: 输入参数
index - 第几根指标线 0-7
array[] - 缓存的数组
void SetIndexDrawBegin( int index, int begin)
设置划线的开始点
:: 输入参数
index - 第几根指标线 0-7
begin - 划线的开始点
void SetIndexLabel( int index, string text)
设置指标线的名称
:: 输入参数
index - 第几根指标线 0-7
text - 线的名称,Null不会显示在数据窗口中
//----
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Tenkan_Buffer);
SetIndexDrawBegin(0,Tenkan-1);
SetIndexLabel(0,"Tenkan Sen");
//----
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,Kijun_Buffer);
SetIndexDrawBegin(1,Kijun-1);
SetIndexLabel(1,"Kijun Sen");
void SetIndexStyle( int index, int type, int style=EMPTY, int width=EMPTY, color clr=CLR_NONE)
设置指标线的样式
:: 输入参数
index - 第几根指标线 0-7
type - 线形状的种类,详见线条种类
style - 划线的样式
width - 显得宽度(1,2,3,4,5)
clr - 线的颜色



网友评论