//自定义函数,这里只是直接使用库函数实现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
//+--------------------------------------------------
#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);
}