MQ4专辑 MT编程入门
MQ4专辑 MT编程入门教程 指标文件构成 自定义指标的基本操作 2010-02-27 22:09
指标文件构成
//例1
//+-----------------------------------iMA(NULL,0,MA_Period,MA_Shift,MA_Method,MA_Price,pos);
pos--;
}
}
//
///----------------------------------------------------------------------
[Copy to clipboard]
例,
CODE:
//+------------------------------------------------------------------+ //双些线后是单行注释,用于注解,自用说明。/*和*/包起来实现多行注释,记录自己的说明介绍,
编程使用记录等
//MQL4语言基本服从C语言的规则-----------注意目前MetaEditor处理不好多字节代码,所以不
要在代码中使用中文和中文空格-------------+ //每个指标文件只是至少包括三个部分(1)property 和参数,数组声明,(2)初始化函数nit(), (3)
主函数start()
//property 是各种说明信息
//最重要必须的是这三种,(1)说明指标将画在价格窗口还是独立的窗口
//(2)有多少个(1~7)储存指标数据的数组,(3)说明对应将画指标的绘画颜色,编号1~7
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Red
#property indicator_color2 Yellow
#property indicator_color3 Blue
#property indicator_color4 Green
#property indicator_color5 Gray
#property indicator_color6 SkyBlue
#property indicator_color7 Tan
//---- 可设置的参数,可根据需要,由使用者设置 extern int MA_Period=13;
extern int MA_Shift=0;
extern int MA_Method=2;
extern int MA_Price = 6;
//数组,储存指标数据
double Buffer0[];
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double Buffer5[];
double Buffer6[];
//----
//+------------------------------------------------------------------+ //| 初始化准备函数,装入时调用一次 | //+------------------------------------------------------------------+ int init()
{
//-设置编号为,的线的线形等参数, 0~6,对应indicator_color1~7
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexStyle(4,DRAW_LINE);
SetIndexStyle(5,DRAW_LINE);
SetIndexStyle(6,DRAW_LINE);
//---- 设置编号为,的线 与数组的对应关系, 0~6
SetIndexBuffer(0,Buffer0);
SetIndexBuffer(1,Buffer1);
SetIndexBuffer(2,Buffer2);
SetIndexBuffer(3,Buffer3);
SetIndexBuffer(4,Buffer4);
SetIndexBuffer(5,Buffer5);
SetIndexBuffer(6,Buffer6);
return(0);
}
//+-------------------------
MQ4专辑MT编程入门 来自淘豆网m.daumloan.com转载请标明出处.