[MT4指标]Bollinger Bandwidth
布林带的一项调查表明,当带宽(顶部和底部带之间的距离)低于4,市场被压缩,即将爆发。当带宽达到11,对于头皮买卖强大的浪潮。
这些数字之间的货币对较弱或压缩的,具有有限的运动,可能会导致花费的时间比盈利更多的损失。此指示灯可让您快速查看带宽的值,并将其运用到你的优势。这是原来的Bands.mq4指标简单地修改代码。
测试了欧元/美元。你可以通过改变最大限制属性更改的最大限制在你是在一个较小的图表周期像M1事件更小的尺寸。
附图指标
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
mt4指标类型:震荡指标
是否能用在mt4手机版上:否
是否含有未来函数:无
//+------------------------------------------------------------------+
//| BandsBandwidth.mq4 |
//| Copyright ? 2009, Investors Haven |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2009, Investors Haven"
#property link ""
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 10000
#property indicator_buffers 1
#property indicator_color1 LightSeaGreen
#property indicator_width1 2
#property indicator_style1 0
//---- indicator parameters
extern int BandsPeriod=20;
extern int BandsShift=0;
extern double BandsDeviations=2.0;
//---- buffers
double MovingBuffer;
double UpperBuffer;
double LowerBuffer;
double Bandwidth;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 3 additional buffers are used for counting.
IndicatorBuffers(4);
//---- indicators
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0,Bandwidth);
SetIndexStyle(1,12);
SetIndexBuffer(1,MovingBuffer);
SetIndexStyle(2,12);
SetIndexBuffer(2,UpperBuffer);
SetIndexStyle(3,12);
SetIndexBuffer(3,LowerBuffer);
//----
SetIndexDrawBegin(0,BandsPeriod+BandsShift);
SetIndexDrawBegin(1,BandsPeriod+BandsShift);
SetIndexDrawBegin(2,BandsPeriod+BandsShift);
SetIndexDrawBegin(3,BandsPeriod+BandsShift);
IndicatorShortName("Bollinger Bandwidth");
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS) - 5);
return(0);
}
//+------------------------------------------------------------------+
//| Bollinger Bands |
//+------------------------------------------------------------------+
int start()
{
int i,k,counted_bars=IndicatorCounted();
double deviation;
double sum,oldval,newres;
Print("here");
//----
if(Bars<=BandsPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=BandsPeriod;i++)
{
MovingBuffer[Bars-i]=EMPTY_VALUE;
UpperBuffer[Bars-i]=EMPTY_VALUE;
LowerBuffer[Bars-i]=EMPTY_VALUE;
Bandwidth[Bars-i]=EMPTY_VALUE;
Print("Buffers cleaned");
}
//----
int limit=Bars-counted_bars;
if(counted_bars>0) limit++;
for(i=0; iBandsPeriod-1) i=Bars-counted_bars-1;
Print("i is:", i);
while(i>=0)
{
sum=0.0;
k=i+BandsPeriod-1;
oldval=MovingBuffer;
while(k>=i)
{
newres=Close[k]-oldval;
sum+=newres*newres;
k--;
}
deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);
UpperBuffer=oldval+deviation;
Print("UpperBuffer is:", UpperBuffer);
LowerBuffer=oldval-deviation;
Print("LowerBuffer is:", LowerBuffer);
Bandwidth=MathFloor((UpperBuffer - LowerBuffer)*10000);
Print("Bandwidth is:", Bandwidth);
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
BandsBandwidth.jpg
