键盘英文切换成中文:看MT4代码,学编程 一
来源:百度文库 编辑:中财网 时间:2024/04/29 02:37:35
1。指标代码解释
- //例1
- //+------------------------------------------------------------------+
- //双些线后是单行注释,用于注解,自用说明。/*和*/包起来实现多行注释,记录自己的说明介绍,编程使用记录等
- //MQL4语言基本服从C语言的规则-----------注意目前MetaEditor处理不好多字节代码,所以不要在代码中使用中文和中文空格-------------+
- //每个指标文件只是至少包括三个部分(1)property 和参数,数组声明,(2)初始化函数nit(), (3)主函数start()
- //property 是各种说明信息
- //最重要必须的是这三种,(1)说明指标将画在价格窗口还是独立的窗口
- //(2)有多少个(1~7)储存指标数据的数组,(3)说明对应将画指标的绘画颜色,编号1~7
- #property indicator_chart_window
- #property indicator_buffers 1
- #property indicator_color1 Red
- //---- 可设置的参数,可根据需要,由使用者设置
- extern int MA_Period=13;
- extern int MA_Shift=0;
- extern int MA_Method=2;
- extern int MA_Price = 6;
- /* MA_Method =
- MODE_SMA 0 Simple moving average,
- MODE_EMA 1 Exponential moving average,
- MODE_SMMA 2 Smoothed moving average,
- MODE_LWMA 3 Linear weighted moving average.
- */
- /* MA_Price =
- PRICE_CLOSE 0 Close price.
- PRICE_OPEN 1 Open price.
- PRICE_HIGH 2 High price.
- PRICE_LOW 3 Low price.
- PRICE_MEDIAN 4 Median price, (high+low)/2.
- PRICE_TYPICAL 5 Typical price, (high+low+close)/3.
- PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.
- */
- //数组,储存指标数据
- double Buffer0[];
- //----
- //+------------------------------------------------------------------+
- //| 初始化准备函数,装入时调用一次 |
- //+------------------------------------------------------------------+
- int init()
- {
- //-设置编号为0的线的线形等参数, 0~6,对应indicator_color1~7
- SetIndexStyle(0,DRAW_LINE);
- //---- 设置编号为0的线 与数组的对应关系, 0~6
- SetIndexBuffer(0,Buffer0);
- return(0);
- }
- //+------------------------------------------------------------------+
- //| |
- int start() //指标计算主函数,每次计算调用
- {
- ma();
- return(0);
- }
- //+------------------------------------------------------------------+
- //|自定义函数,这里只是直接使用库函数实现MA, 若你自己计算,可设计任何指标 |
- //+------------------------------------------------------------------+
- void ma()
- {
- int pos=Bars; //Bars = Number of bars in the current chart.当前窗口中的蜡烛数
- while(pos>=0)
- {
- Buffer0[pos]=iMA(NULL,0,MA_Period,MA_Shift,MA_Method,MA_Price,pos);
- pos--;
- }
- }
- //
- ///----------------------------------------------------------------------
- 例2
-
- //+------------------------------------------------------------------+
- //双些线后是单行注释,用于注解,自用说明。/*和*/包起来实现多行注释,记录自己的说明介绍,编程使用记录等
- //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的线的线形等参数, 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的线 与数组的对应关系, 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);
- }
- //+------------------------------------------------------------------+
- //| |
- int start() //指标计算主函数,每次计算调用
- {
- ma();
- ma1();
- return(0);
- }
- //+------------------------------------------------------------------+
- //|自定义函数,这里只是直接使用库函数实现MA, 若你自己计算,可设计任何指标 |
- //+------------------------------------------------------------------+
- void ma()
- {
- int pos=Bars; //Bars = Number of bars in the current chart.当前窗口中的蜡烛数
- while(pos>=0)
- {
- Buffer0[pos]=iMA(NULL,0,MA_Period,MA_Shift,MA_Method,MA_Price,pos);
- Buffer1[pos]=iMA(NULL,0,MA_Period*2,MA_Shift,MA_Method,MA_Price,pos);
- Buffer2[pos]=iMA(NULL,0,MA_Period*3,MA_Shift,MA_Method,MA_Price,pos);
- pos--;
- }
- }
- void ma1()
- {
- int pos=Bars; //Bars = Number of bars in the current chart.当前窗口中的蜡烛数
- while(pos>=0)
- {
- Buffer3[pos]=iMA(NULL,0,MA_Period*4,MA_Shift,MA_Method,MA_Price,pos);
- Buffer4[pos]=iMA(NULL,0,MA_Period*5,MA_Shift,MA_Method,MA_Price,pos);
- Buffer5[pos]=iMA(NULL,0,MA_Period*6,MA_Shift,MA_Method,MA_Price,pos);
- Buffer6[pos]=iMA(NULL,0,MA_Period*7,MA_Shift,MA_Method,MA_Price,pos);
- pos--;
- }
- }
代码怎样编写?新手学编程该买什么书看
那个网站可以看编程代码
学网路编程看什么书?
我很喜欢编程,但是一学起来非常糊涂,什么c字语言,vb看了一些书就更糊涂了
编程中的原代码看不懂,整么快速学会看代码?
哪位有vc 扩展编程实例一书的代码
求一广告代码,进来看一下
学编程是看视频好还是自己看书好?
请问大家,看哪本编程的书学编程最快(C++)(VC)
我是一名编程爱好者,想学编程,资询一些问题
我是一名编程爱好者,想学编程,资询一些问题
百钱百鸡 VB编程 代码
flash编程,action代码
三角形的编程代码
VB编程代码问题
VB编程代码问题
VB编程代码问题
VB编程代码问题
VB编程代码问题
c#编程改代码
哪儿有最基础的编程教程?本人没有学过,根本不认识代码
学过vb编程的请帮忙解释下这个代码的功能
MT4软件是什么软件?
学编程入门步骤?要成为一名编程高手,首先要从什么方面学起,其次又是什么?