4、E,i);
return(0);
}
-------------------------------------------------------------------------------------------------------
下面是指标叠加的操作方法:
当然这里用的是RSI指标,别的指标如KDJ、威廉等指标也可以类似操作,只要把上面源码中的取值函数和参数换一个行了。
=============================================
语句简要解释如下:
=========================
5、
#property indicator_separate_window
指标放在副图
#property indicator_buffers 1
设置指标线数组为1个
#property indicator_color1 Aqua
设置第一条指标线颜色值为Aqua,即介于蓝绿之间的一种颜色
#property indicator_level1 30
在副图中,30值位置上画一条水平直线
#property indicator_level2 70
在副图中,70值位置上画一条水平直线
extern int RSI=1
6、2;
设立一个自定义变量,允许外部值修改,整数型,变量名为"RSI",默认值12
extern string 商品="GBPUSD";
设立一个自定义变量,允许外部值修改,字符串型,变量名为"商品",默认值"GBPUSD"
double ind_buffer[];
设立一个自定义数组,双精度型
int init()
设立初始化函数init。init为系统规定函数名,函数内容自定义。该函数在指标被加载时运行一次
{
SetIndexBuffer(0,ind_buffer);
设置第一条指标线的数组为ind_buffer
SetIndexStyl
7、e(0,DRAW_LINE,STYLE_SOLID,1);
设置第一条指标线的样式,DRAW_LINE表示连续曲线,STYLE_SOLID表示实心线,1号粗线
IndicatorShortName("RSI("+商品+"," +RSI+")");
设置指标线的显示简称
return(0);
初始化函数结束
}
int start()
设立触发函数start。start为系统规定函数名,函数内容自定义。当数据变动时,start函数被触发
{
int limit;
设立自定义变量limit,整数型
int counte
8、d_bars=IndicatorCounted();
设立整数型自定义变量counted_bars,并将IndicatorCounted()的值赋给counted_bars
IndicatorCounted()为缓存数量,即已经计算过值的烛柱数
(注:可能这里解释得不是很准确,大致就这个意思)
if(counted_bars<0) return(-1);
如果counted_bars值小于零,start函数结束
if(counted_bars>0) counted_bars--;
如果counted_bars值大于零,则counted_b
9、ars值减掉1。这是为了配合下一句,以避免limit相差1而出错
limit=Bars-counted_bars;
给limit赋值
Bars为图表中的柱数
counted_bars为已经赋值的柱数
这样limit的值就是未赋值的烛柱数
这样做的目的是避免重复运算,优化程序
for(int i=0; i