- 注册时间
- 2013-9-23
- 在线时间
- 519 小时
- 最后登录
- 2022-4-4
- 阅读权限
- 200
管理员
MT4软件工程师
- 积分
- 6521
- 帖子
- 2771
- 主题
- 2761
|
MT4智能交易编程示例 Aligator指标
- #property copyright "路路发智能交易研发中心"
- #property link "http://www.ea668.com"
- #property description "Bill Williams' Aligator"
- #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);
- }
- //+------------------------------------------------------------------+
复制代码
|
|