void SetIndexArrow( int index, int code) 在指标上设置一个箭头符号
:: 输入参数
index - 第几根指标线 0-7
code - 符号的编码,参照 Wingdings 字体
示例:
SetIndexArrow(0, 217);
bool SetIndexBuffer( int index, double array[]) 设置指标线的缓存数组
:: 输入参数
index - 第几根指标线 0-7 array[] - 缓存的数组
示例:
double ExtBufferSilver[]; int init() { SetIndexBuffer(0, ExtBufferSilver); // set buffer for first line // ... }
void SetIndexDrawBegin( int index, int begin) 设置划线的开始点
:: 输入参数
index - 第几根指标线 0-7 begin - 划线的开始点
示例:
#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Silver //---- indicator parameters extern int FastEMA=12; extern int SlowEMA=26; extern int SignalSMA=9; //---- indicator buffers double ind_buffer1[]; double ind_buffer2[]; double ind_buffer3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- 2 additional buffers are used for counting. IndicatorBuffers(3); //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3); SetIndexDrawBegin(0,SignalSMA); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2); //---- 3 indicator buffers mapping SetIndexBuffer(0,ind_buffer1); SetIndexBuffer(1,ind_buffer2); SetIndexBuffer(2,ind_buffer3); //---- name for DataWindow and indicator subwindow label IndicatorShortName(\//---- initialization done return(0); }
void SetIndexEmptyValue( int index, double value) 设置划线的空值,空值不划在和出现在数据窗口
:: 输入参数
index - 第几根指标线 0-7 value - 新的空值
示例:
SetIndexEmptyValue(6,0.0001);
void SetIndexLabel( int index, string text) 设置指标线的名称
:: 输入参数
index - 第几根指标线 0-7
text - 线的名称,Null不会显示在数据窗口中
示例:
//+------------------------------------------------------------------+ //| Ichimoku Kinko Hyo initialization function | //+------------------------------------------------------------------+ int init() { //---- SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,Tenkan_Buffer); SetIndexDrawBegin(0,Tenkan-1); SetIndexLabel(0,\//---- SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,Kijun_Buffer); SetIndexDrawBegin(1,Kijun-1); SetIndexLabel(1,\//---- a_begin=Kijun; if(a_begin SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT); SetIndexBuffer(2,SpanA_Buffer); SetIndexDrawBegin(2,Kijun+a_begin-1); SetIndexShift(2,Kijun); //---- Up Kumo bounding line does not show in the DataWindow SetIndexLabel(2,NULL); SetIndexStyle(5,DRAW_LINE,STYLE_DOT); SetIndexBuffer(5,SpanA2_Buffer); SetIndexDrawBegin(5,Kijun+a_begin-1); SetIndexShift(5,Kijun); SetIndexLabel(5,\//---- SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_DOT); SetIndexBuffer(3,SpanB_Buffer); SetIndexDrawBegin(3,Kijun+Senkou-1); SetIndexShift(3,Kijun); //---- Down Kumo bounding line does not show in the DataWindow SetIndexLabel(3,NULL); //---- SetIndexStyle(6,DRAW_LINE,STYLE_DOT); SetIndexBuffer(6,SpanB2_Buffer); SetIndexDrawBegin(6,Kijun+Senkou-1); SetIndexShift(6,Kijun); SetIndexLabel(6,\//---- SetIndexStyle(4,DRAW_LINE); SetIndexBuffer(4,Chinkou_Buffer); SetIndexShift(4,-Kijun); SetIndexLabel(4,\//---- return(0); }
void SetIndexShift( int index, int shift) 设置指标线的位移数
:: 输入参数
index - 第几根指标线 0-7 shift - 位移多少
示例:
//+------------------------------------------------------------------+ //| Alligator initialization function | //+------------------------------------------------------------------+ int init() { //---- line shifts when drawing SetIndexShift(0,JawsShift); SetIndexShift(1,TeethShift); SetIndexShift(2,LipsShift); //---- first positions skipped when drawing SetIndexDrawBegin(0,JawsShift+JawsPeriod); SetIndexDrawBegin(1,TeethShift+TeethPeriod); SetIndexDrawBegin(2,LipsShift+LipsPeriod); //---- 3 indicator buffers mapping SetIndexBuffer(0,ExtBlueBuffer); SetIndexBuffer(1,ExtRedBuffer); SetIndexBuffer(2,ExtLimeBuffer); //---- drawing settings SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexStyle(2,DRAW_LINE); //---- index labels SetIndexLabel(0,\SetIndexLabel(1,\SetIndexLabel(2,\//---- initialization done return(0); }
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 - 线的颜色
示例:
SetIndexStyle(3, DRAW_LINE, EMPTY, 2, Red); 日期时间函数 [Date & Time Functions]
datetime CurTime( ) 返回当前时间 示例:
if(CurTime()-OrderOpenTime()<360) return(0);
int Day() 返回当前日期 示例:
if(Day()<5) return(0);
int DayOfWeek( )
返回当前日期是星期几 0-星期天,1,2,3,4,5,6
示例:
// do not work on holidays. if(DayOfWeek()==0 || DayOfWeek()==6) return(0);
int DayOfYear( ) 返回当前日期在年内的第几天 示例:
if(DayOfYear()==245) return(true);
int Hour()
返回当前的小时数 0-23 示例:
bool is_siesta=false; if(Hour()>=12 || Hour()<17) is_siesta=true;
datetime LocalTime() 返回当前电脑时间 示例:
if(LocalTime()-OrderOpenTime()<360) return(0);
int Minute() 返回当前分钟 示例:
if(Minute()<=15) return(\
int Month() 返回当前月份 示例:
if(Month()<=5) return(\
int Seconds() 返回当前秒数 示例:
if(Seconds()<=15) return(0);
int TimeDay( datetime date) 返回输入日期中的日期