设置指标线开始绘制的位置
void SetIndexDrawBegin(
int index, // 指标线索引号 只能在0-7之间
int begin // 开始绘制的位置
);
指标线从左到右绘制。 开始位置左侧的组值将不会显示在图表或数据窗口中。 0将被设置为默认值,所有数据将被绘制。
示例:
property copyright “www.waihui8.top”
property link “www.waihui8.top”
property description “www.waihui8.top”
property strict
//— 指标设置
property indicator_chart_window
property indicator_buffers 3
property indicator_color1 Blue
property indicator_color2 Red
property indicator_color3 Lime
//— 输入参数
input int InpJawsPeriod=13; // Jaws Period
input int InpJawsShift=8; // Jaws Shift
input int InpTeethPeriod=8; // Teeth Period
input int InpTeethShift=5; // Teeth Shift
input int InpLipsPeriod=5; // Lips Period
input int InpLipsShift=3; // Lips Shift
//— 指标数据buffers
double ExtBlueBuffer[];
double ExtRedBuffer[];
double ExtLimeBuffer[];
//+——————————————————————+
//| 指标初始化函数|
//+——————————————————————+
void OnInit(void)
{
IndicatorDigits(Digits);
//— 设置指标开始显示的位置
SetIndexShift(0,InpJawsShift);
SetIndexShift(1,InpTeethShift);
SetIndexShift(2,InpLipsShift);
//— 绘制指标线时跳过第一个位置SetIndexDrawBegin(0,InpJawsShift+InpJawsPeriod);
SetIndexDrawBegin(1,InpTeethShift+InpTeethPeriod);
SetIndexDrawBegin(2,InpLipsShift+InpLipsPeriod);
//— 3 indicator buffers mapping
SetIndexBuffer(0,ExtBlueBuffer);
SetIndexBuffer(1,ExtRedBuffer);
SetIndexBuffer(2,ExtLimeBuffer);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexLabel(0,”Gator Jaws”);
SetIndexLabel(1,”Gator Teeth”);
SetIndexLabel(2,”Gator Lips”);
}
//+——————————————————————+
//每个价格数据更新时执行
//+——————————————————————+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int limit=rates_total-prev_calculated;
//— 主循环
for(int i=0; i<limit; i++)
{
//— 均线便宜设置为0,因为首先会调用SetIndexShift
ExtBlueBuffer[i]=iMA(NULL,0,InpJawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
ExtRedBuffer[i]=iMA(NULL,0,InpTeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
ExtLimeBuffer[i]=iMA(NULL,0,InpLipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
}
return(rates_total);
}