SetIndexDrawBegin
SetIndexDrawBegin
设置从数据开始处的条形编号,从该编号开始绘制给定的指标线。
void SetIndexDrawBegin(
int index, // line index
int begin // position
);参数
- index
[in] 线条索引。必须在0到7之间。
- begin
[in] 首次绘制条形编号。
返回值
无。
注意
指标从左到右绘制。位于给定条形左侧的指标数组值将不会显示在图表或DataWindow中。默认设置为0,并将绘制所有数据。
示例:
//+------------------------------------------------------------------+
//| Alligator.mq4 |
//| Copyright 2005-2013, MetaQuotes Software Corp. |
//| https://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2013, MetaQuotes Software Corp."
#property link "https://www.mql4.com"
#property description "Bill Williams' Alligator"
#property strict
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Lime
//--- input parameters
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
//--- indicator buffers
double ExtBlueBuffer[];
double ExtRedBuffer[];
double ExtLimeBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
IndicatorDigits(Digits);
//--- line shifts when drawing
SetIndexShift(0,InpJawsShift);
SetIndexShift(1,InpTeethShift);
SetIndexShift(2,InpLipsShift);
//--- first positions skipped when drawing
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);
//--- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
//--- index labels
SetIndexLabel(0,"Gator Jaws");
SetIndexLabel(1,"Gator Teeth");
SetIndexLabel(2,"Gator Lips");
}
//+------------------------------------------------------------------+
//| Bill Williams' Alligator |
//+------------------------------------------------------------------+
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;
//--- main loop
for(int i=0; i<limit; i++)
{
//--- ma_shift set to 0 because SetIndexShift called abowe
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);
}
//--- done
return(rates_total);
}另请参阅
最后更新于