below is the indicator attach.
Code: Select all
#property copyright "Copyright ?2010, Fomenko"
#property link "http://faa1947@mail.ru"
// ----------------- 悟溴朦眍?铌眍 潆 桧滂赅蝾疣 ----------------------------
#property indicator_separate_window
// ---------------- 暑?忸 忤滂禧?狍翦痤?桧滂赅蝾疣 -------------------------
#property indicator_buffers 4
// ---------------- 玉蜞眍怅?鲡弪?桧滂赅蝾疣 --------------------------------
#property indicator_color1 LightSeaGreen
#property indicator_color2 Yellow
#property indicator_color3 Orchid
#property indicator_color4 Red
// ---------------- 玉蜞眍怅?痂睇 腓龛?-----------------------------------
#property indicator_width1 2
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
// ---------------- 玉蜞眍怅?耱桦 腓龛?-----------------------------------
#property indicator_style1 0
#property indicator_style2 0
#property indicator_style3 0
#property indicator_style4 0
//----------------- 马屮龛?磬耱痤殛?桧滂赅蝾疣 ==========--------------------
extern int BandsPeriod = 14; // 襄痂钿 疣聍弪?
extern double BandsDeviations = 1.0; // 洛腓麒磬 耱囗溧痱眍泐 铗觌铐屙?
int BandsShift = 0; // 唁忤?铗眍耔蝈朦眍 沭圄桕?
//----------------- 吾?怆屙桢 狍翦痤?桧桎桕囹铕钼 --------------------------
double MovingBuffer[];
double UpperBuffer[];
double LowerBuffer[];
double Val_BarsBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorDigits (1);
//--------- 茵?忤滂禧?狍翦疣 --------------------------------------
IndicatorBuffers (4);
//---------- 玉蜞眍怅?镟疣戾蝠钼 痂耦忄龛 -------------------------
SetIndexStyle (0, DRAW_LINE);
SetIndexDrawBegin (0, BandsPeriod+BandsShift);
SetIndexStyle (1, DRAW_LINE);
SetIndexDrawBegin (1, BandsPeriod+BandsShift);
SetIndexStyle (2, DRAW_LINE);
SetIndexDrawBegin (2, BandsPeriod+BandsShift);
SetIndexStyle (3, DRAW_HISTOGRAM);
SetIndexDrawBegin (3, BandsPeriod+BandsShift);
//---------- 橡桠琨忄屐 眍戾?狍翦疣 ?邈?桁屙?-------------------
SetIndexBuffer (0, MovingBuffer);
SetIndexBuffer (1, UpperBuffer);
SetIndexBuffer (2, LowerBuffer);
SetIndexBuffer (3, Val_BarsBuffer);
// ----------- 玉蜞磬怆桠噱?镥疴铐圜嚯 珥圜屙? ---------------
SetIndexEmptyValue (0, 0.0);
SetIndexEmptyValue (1, 0.0);
SetIndexEmptyValue (2, 0.0);
SetIndexEmptyValue (3, 0.0);
//------------------ 体蜿?潆 腓龛?桧滂赅蝾疣 ---------------------
SetIndexLabel (0, "Mov");
SetIndexLabel (1, "Up");
SetIndexLabel (2, "Down");
return(0);
}
//+------------------------------------------------------------------+
//| Bollinger Bands |
//+------------------------------------------------------------------+
int start()
{
int i,
k,
counted_bars = IndicatorCounted();
double deviation;
double sum,
oldval,
newres;
//----
if(Bars <= BandsPeriod)
return(0);
//---------------- 蔓麒耠屐 耩邃睨?--------------------------------
int limit = Bars - counted_bars;
if(counted_bars > 0)
limit++;
for(i = 0; i < limit; i++)
Val_BarsBuffer[i] = (High[i] - Low[i]) / Point;
for(i = 0; i < limit; i++)
MovingBuffer[i] = iMAOnArray(Val_BarsBuffer,
Bars,
BandsPeriod,
BandsShift,
MODE_SMA, // MODE_SMA, MODE_EMA, MODE_SMMA, MODE_LWMA
i);
//--------------- 蔓麒耠屐 耱铕铐?赅磬豚 ----------------------------
i = Bars - BandsPeriod + 1;
if(counted_bars > BandsPeriod - 1)
i = Bars - counted_bars - 1;
while(i >= 0)
{
sum = 0.0;
k = i + BandsPeriod - 1;
oldval = MovingBuffer[i];
while(k >= i)
{
newres = Val_BarsBuffer[k] - oldval;
sum += newres * newres;
k--;
}
deviation = BandsDeviations * MathSqrt(sum / BandsPeriod);
UpperBuffer[i] = oldval + deviation;
LowerBuffer[i] = oldval - deviation;
i--;
}
//----------------- 软滂赅蝾?恹麒耠屙 --------------------------------
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}