Proshu pomoschi s indikatorom dlja MT4

 
Pojavilsja na svet indikator. Eto neskoljko T3 s raznimi periodami v odnom okne. No v njem kokaja to oshibka - liniji na tekushem bare sjezhajutsja v odnu: vot kartinka
Hochu poprositj umeljcev gljanutj, i jesli mozhno, popravitj.

Kod T3:
[Просим оформлять MQL4 код соответствующим образом]
Zaranee blagodaren.
 
убедительная просьба - оформлять исходные тексты надлежащим образом!!! заключайте исходники в теги pre. ну пожалуйста!
 
Izvenjajusj, nadejusj vot tak luchshe:

T3:
//+------------------------------------------------------------------+ 
//|                                                           T3.mq4 | 
//+------------------------------------------------------------------+ 

#property copyright "MojoFX - Conversion only"
#property link      "http://groups.yahoo.com/group/MetaTrader_Experts_and_Indicators/"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

extern int MA_Period = 14;
extern double b = 0.7;

double MapBuffer[];

double e1,e2,e3,e4,e5,e6;
double c1,c2,c3,c4;
double n,w1,w2,b2,b3;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators setting
    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,Red);
    IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
    IndicatorShortName("Moving Average "+MA_Period);
    
    SetIndexBuffer(0,MapBuffer);

//---- variable reset
    e1=0; e2=0; e3=0; e4=0; e5=0; e6=0;
    c1=0; c2=0; c3=0; c4=0; 
    n=0; 
    w1=0; w2=0; 
    b2=0; b3=0;

    b2=b*b;
    b3=b2*b;
    c1=-b3;
    c2=(3*(b2+b3));
    c3=-3*(2*b2+b+b3);
    c4=(1+3*b+b3+3*b2);
    n=MA_Period;

    if (n<1) n=1;
    n = 1 + 0.5*(n-1);
    w1 = 2 / (n + 1);
    w2 = 1 - w1;
    
//----
    return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if (counted_bars<0) return (-1);
   if (counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

//---- indicator calculation

    for(int i=limit; i>=0; i--)
    {
        e1 = w1*Close[i] + w2*e1;
        e2 = w1*e1 + w2*e2;
        e3 = w1*e2 + w2*e3;
        e4 = w1*e3 + w2*e4;
        e5 = w1*e4 + w2*e5;
        e6 = w1*e5 + w2*e6;
    
        MapBuffer[i]=c1*e6 + c2*e5 + c3*e4 + c4*e3;
    }   
//----
   return(0);
  }
//+------------------------------------------------------------------+



A vot sam indikator:

//+------------------------------------------------------------------+
//| T3_Bands.mq4 |
//| 
//| |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Yellow
#property indicator_color5 Silver
#property indicator_color6 Black

extern int MA_Period_1 = 5;
extern int MA_Period_2 = 15;
extern int MA_Period_3 = 20;
extern int MA_Period_4 = 35;
extern int MA_Period_5 = 80;
extern int MA_Period_6 = 280;
#include ""

extern double b = 0.86;

double MapBuffer1[];
double MapBuffer2[];
double MapBuffer3[];
double MapBuffer4[];
double MapBuffer5[];
double MapBuffer6[];

double e1[6],e2[6],e3[6],e4[6],e5[6],e6[6];
double c1[6],c2[6],c3[6],c4[6];
double n[6],w1[6],w2[6],b2[6],b3[6];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators setting
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,Green);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,Red);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1,Blue);
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1,Yellow);
SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,1,Silver);
SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,2,Black);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
IndicatorShortName("T3 Bands");

SetIndexBuffer(0,MapBuffer1);
SetIndexBuffer(1,MapBuffer2);
SetIndexBuffer(2,MapBuffer3);
SetIndexBuffer(3,MapBuffer4);
SetIndexBuffer(4,MapBuffer5);
SetIndexBuffer(5,MapBuffer6);
//---- variable reset
n[1]=MA_Period_1;
n[2]=MA_Period_2;
n[3]=MA_Period_3;
n[4]=MA_Period_4;
n[5]=MA_Period_5;
n[6]=MA_Period_6;

for(int l=1; l<7; l++)
{

e1[l]=0; e2[l]=0; e3[l]=0; e4[l]=0; e5[l]=0; e6[l]=0;
c1[l]=0; c2[l]=0; c3[l]=0; c4[l]=0; 
w1[l]=0; w2[l]=0; 
b2[l]=0; b3[l]=0;

b2[l]=b*b;
b3[l]=b2[l]*b;
c1[l]=-b3[l];
c2[l]=(3*(b2[l]+b3[l]));
c3[l]=-3*(2*b2[l]+b+b3[l]);
c4[l]=(1+3*b+b3[l]+3*b2[l]);

if (n[l]<1) n[l]=1;
n[l] = 1 + 0.5*(n[l]-1);
w1[l] = 2 / (n[l] + 1);
w2[l] = 1 - w1[l];
}



//----
return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit,MB[],ii,i;
int counted_bars=IndicatorCounted();
if (counted_bars<0) return (-1);
if (counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- indicator calculation



for(i=limit; i>=0; i--)
{

for(ii=1; ii<7; ii++)
{
e1[ii] = w1[ii]*Close[i] + w2[ii]*e1[ii];
e2[ii] = w1[ii]*e1[ii] + w2[ii]*e2[ii];
e3[ii] = w1[ii]*e2[ii] + w2[ii]*e3[ii];
e4[ii] = w1[ii]*e3[ii] + w2[ii]*e4[ii];
e5[ii] = w1[ii]*e4[ii] + w2[ii]*e5[ii];
e6[ii] = w1[ii]*e5[ii] + w2[ii]*e6[ii];

if (ii==1) MapBuffer1[i]=c1[ii]*e6[ii] + c2[ii]*e5[ii] + c3[ii]*e4[ii] + c4[ii]*e3[ii];
if (ii==2) MapBuffer2[i]=c1[ii]*e6[ii] + c2[ii]*e5[ii] + c3[ii]*e4[ii] + c4[ii]*e3[ii];
if (ii==3) MapBuffer3[i]=c1[ii]*e6[ii] + c2[ii]*e5[ii] + c3[ii]*e4[ii] + c4[ii]*e3[ii];
if (ii==4) MapBuffer4[i]=c1[ii]*e6[ii] + c2[ii]*e5[ii] + c3[ii]*e4[ii] + c4[ii]*e3[ii];
if (ii==5) MapBuffer5[i]=c1[ii]*e6[ii] + c2[ii]*e5[ii] + c3[ii]*e4[ii] + c4[ii]*e3[ii];
if (ii==6) MapBuffer6[i]=c1[ii]*e6[ii] + c2[ii]*e5[ii] + c3[ii]*e4[ii] + c4[ii]*e3[ii];
}
}

//----
return(0);
}
//+------------------------------------------------------------------+
Причина обращения: