下载MetaTrader 5
要添加评论,请登录注册
需要MetaTrader 5的移动版吗?下载它并进行交易!
Hongming Huo
25
Hongming Huo 2014.03.01 23:06 

从布林带 改的代码 一个12均线 一个 26均线

我想在连个均线之间填充颜色???

请问 怎么搞???是用Draw_Fill么? 如何做?


//+------------------------------------------------------------------+
//| |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| https://www.mql5.com/go?link=https://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "https://www.mql5.com/go?link=https://www.mql4.com"
#property description "Bollinger Bands"
#property strict

#include <MovingAverages.mqh>

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Magenta
#property indicator_color2 MediumSpringGreen
//--- indicator parameters

input int FasterMA = 12;
input int SlowerMA = 26;

//--- buffers
double Fast_MA[];
double Slow_MA[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
//--- 1 additional buffer used for counting.
IndicatorBuffers(2);
IndicatorDigits(Digits);
//--- middle line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Fast_MA);
SetIndexShift(0,0);
SetIndexLabel(0,"Fast_MA");
//--- upper band
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,Slow_MA);
SetIndexShift(1,0);
SetIndexLabel(1,"Slow_MA");
//--- work buffer

//--- check for input parameter
if(SlowerMA<=0)
{
Print("Wrong input parameter Bands Period=",FasterMA);
return(INIT_FAILED);
}
//---
SetIndexDrawBegin(0,SlowerMA);

//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Bollinger Bands |
//+------------------------------------------------------------------+
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
Fast_MA[i]=iMA(NULL,0,FasterMA,0,MODE_EMA,PRICE_CLOSE,i);
Slow_MA[i]=iMA(NULL,0,SlowerMA,0,MODE_EMA,PRICE_CLOSE,i);
}

//---- OnCalculate done. Return new prev_calculated.
return(rates_total);
}

/
要添加评论,请登录注册