MT4(MQL4)均线组指标附源码
//+------------------------------------------------------------------+//| ind_mas.mq4 |//| 龙听期货论坛 |//| http://www.qhlt.cn |//+------------------------------------------------------------------+#property copyright "龙听期货论坛"#property link "http://www.qhlt.cn"#property version "1.00"#property strict#property indicator_chart_window#property indicator_buffers 10#property indicator_plots 10#include<CommonMath.mqh>#include<MovingAverages.mqh>//--- plot ma1#property indicator_label1 "ma1"#property indicator_type1 DRAW_LINE#property indicator_color1 clrWhite#property indicator_style1 STYLE_SOLID#property indicator_width1 1//--- plot ma2#property indicator_label2 "ma2"#property indicator_type2 DRAW_LINE#property indicator_color2 clrYellow#property indicator_style2 STYLE_SOLID#property indicator_width2 1//--- plot ma3#property indicator_label3 "ma3"#property indicator_type3 DRAW_LINE#property indicator_color3 clrGreen#property indicator_style3 STYLE_SOLID#property indicator_width3 1//--- plot ma4#property indicator_label4 "ma4"#property indicator_type4 DRAW_LINE#property indicator_color4 clrRed#property indicator_style4 STYLE_SOLID#property indicator_width4 1//--- plot ma5#property indicator_label5 "ma5"#property indicator_type5 DRAW_LINE#property indicator_color5 clrPurple#property indicator_style5 STYLE_SOLID#property indicator_width5 1//--- plot ma6#property indicator_label6 "ma6"#property indicator_type6 DRAW_LINE#property indicator_color6 clrAquamarine#property indicator_style6 STYLE_SOLID#property indicator_width6 1//--- plot ma7#property indicator_label7 "ma7"#property indicator_type7 DRAW_LINE#property indicator_color7 clrRed#property indicator_style7 STYLE_SOLID#property indicator_width7 1//--- plot ma8#property indicator_label8 "ma8"#property indicator_type8 DRAW_LINE#property indicator_color8 clrRed#property indicator_style8 STYLE_SOLID#property indicator_width8 1//--- plot ma9#property indicator_label9 "ma9"#property indicator_type9 DRAW_LINE#property indicator_color9 clrRed#property indicator_style9 STYLE_SOLID#property indicator_width9 1//--- plot ma10#property indicator_label10 "ma10"#property indicator_type10 DRAW_LINE#property indicator_color10 clrRed#property indicator_style10 STYLE_SOLID#property indicator_width10 1//--- input parametersinput int Input1=5;input int Input2=10;input int Input3=20;input int Input4=30;input int Input5=60;input int Input6=120;input int Input7=250;input int Input8=0;input int Input9=0;input int Input10=0;//--- indicator buffersdouble ma1Buffer[];double ma2Buffer[];double ma3Buffer[];double ma4Buffer[];double ma5Buffer[];double ma6Buffer[];double ma7Buffer[];double ma8Buffer[];double ma9Buffer[];double ma10Buffer[];//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit(){//--- indicator buffers mappingSetIndexBuffer(0,ma1Buffer);SetIndexBuffer(1,ma2Buffer);SetIndexBuffer(2,ma3Buffer);SetIndexBuffer(3,ma4Buffer);SetIndexBuffer(4,ma5Buffer);SetIndexBuffer(5,ma6Buffer);SetIndexBuffer(6,ma7Buffer);SetIndexBuffer(7,ma8Buffer);SetIndexBuffer(8,ma9Buffer);SetIndexBuffer(9,ma10Buffer);//---return(INIT_SUCCEEDED);}//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint 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[]){//---if(rates_total <= Max3(Input1,Input2,Input10))return 0;SimpleMAOnBuffer(rates_total,prev_calculated,0,Input1,close,ma1Buffer);SimpleMAOnBuffer(rates_total,prev_calculated,0,Input2,close,ma2Buffer);SimpleMAOnBuffer(rates_total,prev_calculated,0,Input3,close,ma3Buffer);SimpleMAOnBuffer(rates_total,prev_calculated,0,Input4,close,ma4Buffer);SimpleMAOnBuffer(rates_total,prev_calculated,0,Input5,close,ma5Buffer);SimpleMAOnBuffer(rates_total,prev_calculated,0,Input6,close,ma6Buffer);SimpleMAOnBuffer(rates_total,prev_calculated,0,Input7,close,ma7Buffer);SimpleMAOnBuffer(rates_total,prev_calculated,0,Input8,close,ma8Buffer);SimpleMAOnBuffer(rates_total,prev_calculated,0,Input9,close,ma9Buffer);SimpleMAOnBuffer(rates_total,prev_calculated,0,Input10,close,ma10Buffer);//--- return value of prev_calculated for next callreturn(rates_total);}//+------------------------------------------------------------------+
CommonMath.mqh
#property copyright "龙听期货论坛"#property link "http://www.qhlt.cn"#property strict#ifndef __COMMON_MATH_MQH__#define __COMMON_MATH_MQH__doubleMax3(double a, double b, double c){return MathMax(a, MathMax(b, c));}doubleMin3(double a, double b, double c){return MathMin(a, MathMin(b, c));}#endif
求三个数中最大最小的max3,min3.
MovingAverages.mqhp 这个是官网自带的,就不发出来了。
设计后效果图如下:

模板是东财或文华版。
关注微信:


夜雨聆风
