M:1,11111,12:
N:2,3,2:
D:2,3,3:
MA9 : MA(CLOSE,M*(9/12)*(N/2)*(D/3)),COLORRED,LINETHICK2;
MA12 : MA(CLOSE,M*(N/2)*(D/3)),COLORYELLOW,LINETHICK2;
MA18 : MA(CLOSE,M*2*(9/12)*(N/2)*(D/3)),COLORRED,LINETHICK2;
MA27 : MA(CLOSE,M*(27/12)*(N/2)*(D/3)),COLORGREEN,LINETHICK2;
UP: MA27 + 1*STD(CLOSE,M*(27/12)*(N/2)*(D/3)),COLORGREEN,DOTLINE;
LO: MA27 - 1*STD(CLOSE,M*(27/12)*(N/2)*(D/3)),COLORGREEN,DOTLINE;
UP1: MA27 + 2*STD(CLOSE,M*(27/12)*(N/2)*(D/3)),COLORRED,DOTLINE;
LO1: MA27 - 2*STD(CLOSE,M*(27/12)*(N/2)*(D/3)),COLORRED,DOTLINE;
下面是MT4的均线代码 ——只需要在这个基础上把布林加上就可以了,老师!非常感谢您!
//+------------------------------------------------------------------+
//| 三色均线指标.mq4 |
//| Copyright 2019, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots 3
//--- plot MA1
#property indicator_label1 "MA9"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrRed
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- plot MA2
#property indicator_label2 "MA12"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrYellow
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
//--- plot MA3
#property indicator_label3 "MA26"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrGreen
#property indicator_style3 STYLE_SOLID
#property indicator_width3 1
//--- indicator buffers
double MA1Buffer[];
double MA2Buffer[];
double MA3Buffer[];
input int M=12;//
input int N=2;//
input int D=3;//
input int shift=0;//平移
input ENUM_MA_METHOD method=MODE_SMA;//类型
input ENUM_APPLIED_PRICE price=PRICE_CLOSE;//应用于
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,MA1Buffer);
SetIndexBuffer(1,MA2Buffer);
SetIndexBuffer(2,MA3Buffer);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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 shu=0;
if(prev_calculated==0)
{
shu=rates_total;
}
else
{
shu=rates_total-prev_calculated+1;
}
for(int i=0;i<shu;i++)
{
MA1Buffer[i]=iMA(Symbol(),0,(int)(M*(9.0/12.0)*(N/2.0)*(D/3.0)),shift,method,price,i);
MA2Buffer[i]=iMA(Symbol(),0,(int)(M*(N/2.0)*(D/3.0)),shift,method,price,i);
MA3Buffer[i]=iMA(Symbol(),0,(int)(M*(26.0/12.0)*(N/2.0)*(D/3.0)),shift,method,price,i);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+