//+------------------------------------------------------------------+
//|                         JMA_Multi_Osc(AM)  (JMA WPR fo Spiggy)   |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "Andrey Matvievskiy"
//----
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Gold
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2

//---- input parameters

extern int           Len=7;
extern int         phase=0;
extern int   BarCount=1000;

extern int           Ind=1;
extern int         Per1=14;
extern int          Per2=7;
extern int        Price1=0;
extern int        Price2=0;
extern int       Method1=0;
extern int       Method2=0;

//---- buffers

double j[];
double jhi[];
double jlo[];


double a1=0.0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,j);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,jhi);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,jlo);
   
//----

     if(Ind<1 || Ind>38)
	 {
	  Alert("Неправильно задан параметр!");
	  Ind=1;
	 }

   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//---- 
   // variable definitions
   bool firstTime=True;
   int AccountedBars=0;
   int jj=0;
   int ii=0;
   int shift=0;
   double series=0;
//----
    
   double vv=0;
   double v1=0;
   double v2=0;
   double v3=0;
   double v4=0;
   double s8=0;
   double s10=0;
   double s18=0;
   double s20=0;
   int v5=0;
   int v6=0;
   double s28=0;
   double s30=0;
   int s38=0;
   int s40=0;
   int s48=0;
   int s50=0;
   int s58=0;
   int s60=0;
   double s68=0;
   double s70=0;
   double f8=0;
   double f10=0;
   double f18=0;
   double f20=0;
   double f28=0;
   double f30=0;
   double f38=0;
   double f40=0;
   double f48=0;
   double f50=0;
   double f58=0;
   double f60=0;
   double f68=0;
   double f70=0;
   double f78=0;
   double f80=0;
   double f88=0;
   double f90=0;
   double f98=0;
   double fA0=0;
   double fA8=0;
   double fB0=0;
   double fB8=0;
   double fC0=0;
   double fC8=0;
   double fD0=0;
   double f0=0;
   double fD8=0;
   double fE0=0;
   double fE8=0;
   int fF0=0;
   double fF8=0;
   int value2=0;
   double JMA=0;

//----
   double list[127];
   double ring1[127];
   double ring2[10];
   double buffer[61];
//----
   ArrayInitialize(list,0);
   ArrayInitialize(ring1,0);
   ArrayInitialize(ring2,0);
   ArrayInitialize(buffer,0);
//----
   if (firstTime)
     {
      AccountedBars=Bars-BarCount;
      firstTime=False;
     }

   //SetLoopCount(0); 
     {
      s28=63;
      s30=64;
      for( ii=1;ii<=s28;ii++)
        {
         list[ii]=-1000000;
        }
      for( ii=s30;ii<=127 ;ii++ )
        {
         list[ii]=1000000;
        }
      f0=1;
     }
//----
 
   for( shift=BarCount;shift>=0;shift-- )
    {
    {
    switch(Ind)
    {       
    case 1:  a1 = iMA(NULL,0,Per1,0,Method1,Price1,shift);break;//MA
    case 2:  a1 = iMA(NULL,0,Per2,0,Method2,Price2,shift)-iMA(NULL,0,Per1,0,Method1,Price1,shift);break;//MACD
    case 3:  a1 = (iMA(NULL,0,(Per1/2),0,3,Price1,shift)*2)-iMA(NULL,0,Per1,0,3,Price1,shift);break;//HULL MA
    case 4:  a1 = ((iMA(NULL,0,(Per2/2),0,Method2,Price2,shift)*2)-iMA(NULL,0,Per2,0,Method2,Price2,shift))
             -((iMA(NULL,0,(Per1/2),0,Method1,Price1,shift)*2)-iMA(NULL,0,Per1,0,Method1,Price1,shift));break;//HULL MACD
    case 5:  a1 = (iMA(NULL,0,Per1,0,0,Price1,shift)*3)-(iMA(NULL,0,Per1,0,3,Price1,shift)*2);break;//LRMA MA 
    case 6:  a1 = ((iMA(NULL,0,Per2,0,0,Price2,shift)*3)-(iMA(NULL,0,Per2,0,3,Price2,shift)*2))
             -((iMA(NULL,0,Per1,0,0,Price1,shift)*3)-(iMA(NULL,0,Per1,0,3,Price1,shift)*2));break;//LRMA MACD
      
    case 7:  a1 = iRSI(NULL,0,Per1,Price1,shift)-50;break;
    case 8:  a1 = (iRSI(NULL,0,Per2,Price1,shift)-50)-(iRSI(NULL,0,Per1,Price1,shift)-50);break;
    
    case 9:  a1 = iMFI(NULL,0,Per1,shift)-50;break;
    case 10: a1 = (iMFI(NULL,0,Per2,shift)-50)-(iMFI(NULL,0,Per1,shift)-50);break;
    
    case 11: a1 = iMomentum(NULL,0,Per1,Price1,shift)-100;break; 
    case 12: a1 = iDeMarker(NULL,0,Per1,shift)-0.5;break;
       
    case 13: a1 = iADX(NULL,0,Per1,0,1,shift)-iADX(NULL,0,Per1,0,2,shift);break;
    case 14: a1 = iADX(NULL,0,Per1,0,0,shift);break;
    case 15: a1 = iADX(NULL,0,Per1,0,1,shift);break;
    case 16: a1 = iADX(NULL,0,Per1,0,2,shift);break;
    
    case 17: a1 = iWPR(NULL,0,Per1,shift)+50;break;
    case 18: a1 = iCCI(NULL,0,Per1,Price1,shift);break;
    case 19: a1 = iAD(NULL,0,shift);break;
    case 20: a1 = iATR(NULL,0,Per1,shift);break;
    case 21: a1 = iOBV(NULL,0,Price1,shift);break;
    case 22: a1 = iStdDev(NULL,0,Per1,0,Method1,Price1,shift);break;
    case 23: a1 = iRVI(NULL,0,Per1,0,shift);break;
    
    case 24: double X = Per1/2+1 ;a1 = Close[shift] - iMA(NULL, 0, Per1, X, Method1, Price1, shift);break;//DPO
    
    case 25: a1 = iAO(NULL,0,shift);break;
    case 26: a1 = iAC(NULL,0,shift);break;
    
    case 27: a1 = 0.4360409450*Close[shift+0]+0.3658689069*Close[shift+1]+0.2460452079*Close[shift+2]+0.1104506886*Close[shift+3]
                -0.0054034585*Close[shift+4]-0.0760367731*Close[shift+5]-0.0933058722*Close[shift+6]-0.0670110374*Close[shift+7]
                -0.0190795053*Close[shift+8]+0.0259609206*Close[shift+9]+0.0502044896*Close[shift+10]+0.0477818607*Close[shift+11]
                +0.0249252327*Close[shift+12]-0.0047706151*Close[shift+13]-0.0272432537*Close[shift+14]-0.0338917071*Close[shift+15]
                -0.0244141482*Close[shift+16]-0.0055774838*Close[shift+17]+0.0128149838*Close[shift+18]+0.0226522218*Close[shift+19]
                +0.0208778257*Close[shift+20]+0.0100299086*Close[shift+21]-0.0036771622*Close[shift+22]-0.0136744850*Close[shift+23]
                -0.0160483392*Close[shift+24]-0.0108597376*Close[shift+25]-0.0016060704*Close[shift+26]+0.0069480557*Close[shift+27]
                +0.0110573605*Close[shift+28]+0.0095711419*Close[shift+29]+0.0040444064*Close[shift+30]-0.0023824623*Close[shift+31]
                -0.0067093714*Close[shift+32]-0.0072003400*Close[shift+33]-0.0047717710*Close[shift+34]+0.0005541115*Close[shift+35]
                +0.0007860160*Close[shift+36]+0.0130129076*Close[shift+37]+0.0040364019*Close[shift+38];break;//FATL
    
    case 28: a1 = 0.0982862174*Close[shift+0]+0.0975682269*Close[shift+1]+0.0961401078*Close[shift+2]+0.0940230544*Close[shift+3] 
                +0.0912437090*Close[shift+4]+0.0878391006*Close[shift+5]+0.0838544303*Close[shift+6]+0.0793406350*Close[shift+7] 
                +0.0743569346*Close[shift+8]+0.0689666682*Close[shift+9]+0.0632381578*Close[shift+10]+0.0572428925*Close[shift+11] 
                +0.0510534242*Close[shift+12]+0.0447468229*Close[shift+13]+0.0383959950*Close[shift+14]+0.0320735368*Close[shift+15] 
                +0.0258537721*Close[shift+16]+0.0198005183*Close[shift+17]+0.0139807863*Close[shift+18]+0.0084512448*Close[shift+19] 
                +0.0032639979*Close[shift+20]-0.0015350359*Close[shift+21]-0.0059060082*Close[shift+22]-0.0098190256*Close[shift+23] 
                -0.0132507215*Close[shift+24]-0.0161875265*Close[shift+25]-0.0186164872*Close[shift+26]-0.0205446727*Close[shift+27] 
                -0.0219739146*Close[shift+28]-0.0229204861*Close[shift+29]-0.0234080863*Close[shift+30]-0.0234566315*Close[shift+31] 
                -0.0231017777*Close[shift+32]-0.0223796900*Close[shift+33]-0.0213300463*Close[shift+34]-0.0199924534*Close[shift+35] 
                -0.0184126992*Close[shift+36]-0.0166377699*Close[shift+37]-0.0147139428*Close[shift+38]-0.0126796776*Close[shift+39] 
                -0.0105938331*Close[shift+40]-0.0084736770*Close[shift+41]-0.0063841850*Close[shift+42]-0.0043466731*Close[shift+43] 
                -0.0023956944*Close[shift+44]-0.0005535180*Close[shift+45]+0.0011421469*Close[shift+46]+0.0026845693*Close[shift+47] 
                +0.0040471369*Close[shift+48]+0.0052380201*Close[shift+49]+0.0062194591*Close[shift+50]+0.0070340085*Close[shift+51] 
                +0.0076266453*Close[shift+52]+0.0080376628*Close[shift+53]+0.0083037666*Close[shift+54]+0.0083694798*Close[shift+55] 
                +0.0082901022*Close[shift+56]+0.0080741359*Close[shift+57]+0.0077543820*Close[shift+58]+0.0073260526*Close[shift+59] 
                +0.0068163569*Close[shift+60]+0.0062325477*Close[shift+61]+0.0056078229*Close[shift+62]+0.0049516078*Close[shift+63] 
                +0.0161380976*Close[shift+64];break;//SATL
    
     case 29: a1 = Close[shift] - 
                (0.4360409450*Close[shift+0]+0.3658689069*Close[shift+1]+0.2460452079*Close[shift+2]+0.1104506886*Close[shift+3]
                -0.0054034585*Close[shift+4]-0.0760367731*Close[shift+5]-0.0933058722*Close[shift+6]-0.0670110374*Close[shift+7]
                -0.0190795053*Close[shift+8]+0.0259609206*Close[shift+9]+0.0502044896*Close[shift+10]+0.0477818607*Close[shift+11]
                +0.0249252327*Close[shift+12]-0.0047706151*Close[shift+13]-0.0272432537*Close[shift+14]-0.0338917071*Close[shift+15]
                -0.0244141482*Close[shift+16]-0.0055774838*Close[shift+17]+0.0128149838*Close[shift+18]+0.0226522218*Close[shift+19]
                +0.0208778257*Close[shift+20]+0.0100299086*Close[shift+21]-0.0036771622*Close[shift+22]-0.0136744850*Close[shift+23]
                -0.0160483392*Close[shift+24]-0.0108597376*Close[shift+25]-0.0016060704*Close[shift+26]+0.0069480557*Close[shift+27]
                +0.0110573605*Close[shift+28]+0.0095711419*Close[shift+29]+0.0040444064*Close[shift+30]-0.0023824623*Close[shift+31]
                -0.0067093714*Close[shift+32]-0.0072003400*Close[shift+33]-0.0047717710*Close[shift+34]+0.0005541115*Close[shift+35]
                +0.0007860160*Close[shift+36]+0.0130129076*Close[shift+37]+0.0040364019*Close[shift+38]);break;//PCCI-FATL
                
    case 30: a1 = Close[shift] -             
                (0.0982862174*Close[shift+0]+0.0975682269*Close[shift+1]+0.0961401078*Close[shift+2]+0.0940230544*Close[shift+3] 
                +0.0912437090*Close[shift+4]+0.0878391006*Close[shift+5]+0.0838544303*Close[shift+6]+0.0793406350*Close[shift+7] 
                +0.0743569346*Close[shift+8]+0.0689666682*Close[shift+9]+0.0632381578*Close[shift+10]+0.0572428925*Close[shift+11] 
                +0.0510534242*Close[shift+12]+0.0447468229*Close[shift+13]+0.0383959950*Close[shift+14]+0.0320735368*Close[shift+15] 
                +0.0258537721*Close[shift+16]+0.0198005183*Close[shift+17]+0.0139807863*Close[shift+18]+0.0084512448*Close[shift+19] 
                +0.0032639979*Close[shift+20]-0.0015350359*Close[shift+21]-0.0059060082*Close[shift+22]-0.0098190256*Close[shift+23] 
                -0.0132507215*Close[shift+24]-0.0161875265*Close[shift+25]-0.0186164872*Close[shift+26]-0.0205446727*Close[shift+27] 
                -0.0219739146*Close[shift+28]-0.0229204861*Close[shift+29]-0.0234080863*Close[shift+30]-0.0234566315*Close[shift+31] 
                -0.0231017777*Close[shift+32]-0.0223796900*Close[shift+33]-0.0213300463*Close[shift+34]-0.0199924534*Close[shift+35] 
                -0.0184126992*Close[shift+36]-0.0166377699*Close[shift+37]-0.0147139428*Close[shift+38]-0.0126796776*Close[shift+39] 
                -0.0105938331*Close[shift+40]-0.0084736770*Close[shift+41]-0.0063841850*Close[shift+42]-0.0043466731*Close[shift+43] 
                -0.0023956944*Close[shift+44]-0.0005535180*Close[shift+45]+0.0011421469*Close[shift+46]+0.0026845693*Close[shift+47] 
                +0.0040471369*Close[shift+48]+0.0052380201*Close[shift+49]+0.0062194591*Close[shift+50]+0.0070340085*Close[shift+51] 
                +0.0076266453*Close[shift+52]+0.0080376628*Close[shift+53]+0.0083037666*Close[shift+54]+0.0083694798*Close[shift+55] 
                +0.0082901022*Close[shift+56]+0.0080741359*Close[shift+57]+0.0077543820*Close[shift+58]+0.0073260526*Close[shift+59] 
                +0.0068163569*Close[shift+60]+0.0062325477*Close[shift+61]+0.0056078229*Close[shift+62]+0.0049516078*Close[shift+63] 
                +0.0161380976*Close[shift+64]);break;//PCCI-SATL
    
    case 31: a1 = Close[shift] -  
                (-0.0025097319*Close[shift+0]+0.0513007762*Close[shift+1]+0.1142800493*Close[shift+2]+0.1699342860*Close[shift+3] 
                +0.2025269304*Close[shift+4]+0.2025269304*Close[shift+5]+0.1699342860*Close[shift+6]+0.1142800493*Close[shift+7] 
                +0.0513007762*Close[shift+8]-0.0025097319*Close[shift+9]-0.0353166244*Close[shift+10]-0.0433375629*Close[shift+11] 
                -0.0311244617*Close[shift+12]-0.0088618137*Close[shift+13]+0.0120580088*Close[shift+14]+0.0233183633*Close[shift+15] 
                +0.0221931304*Close[shift+16]+0.0115769653*Close[shift+17]-0.0022157966*Close[shift+18]-0.0126536111*Close[shift+19] 
                -0.0157416029*Close[shift+20]-0.0113395830*Close[shift+21]-0.0025905610*Close[shift+22]+0.0059521459*Close[shift+23] 
                +0.0105212252*Close[shift+24]+0.0096970755*Close[shift+25]+0.0046585685*Close[shift+26]-0.0017079230*Close[shift+27] 
                -0.0063513565*Close[shift+28]-0.0074539350*Close[shift+29]-0.0050439973*Close[shift+30]-0.0007459678*Close[shift+31] 
                +0.0032271474*Close[shift+32]+0.0051357867*Close[shift+33]+0.0044454862*Close[shift+34]+0.0018784961*Close[shift+35] 
                -0.0011065767*Close[shift+36]-0.0031162862*Close[shift+37]-0.0033443253*Close[shift+38]-0.0022163335*Close[shift+39] 
                +0.0002573669*Close[shift+40]+0.0003650790*Close[shift+41]+0.0060440751*Close[shift+42]
                +0.0018747783*Close[shift+43]);break;//PCCI-RFTL
    
     case 32: a1 = Close[shift] -  
                (-0.00514293*Close[shift+0]-0.00398417*Close[shift+1]-0.00262594*Close[shift+2]-0.00107121*Close[shift+3] 
                +0.00066887*Close[shift+4]+0.00258172*Close[shift+5]+0.00465269*Close[shift+6]+0.00686394*Close[shift+7] 
                +0.00919334*Close[shift+8]+0.01161720*Close[shift+9]+0.01411056*Close[shift+10]+0.01664635*Close[shift+11] 
                +0.01919533*Close[shift+12]+0.02172747*Close[shift+13]+0.02421320*Close[shift+14]+0.02662203*Close[shift+15] 
                +0.02892446*Close[shift+16]+0.03109071*Close[shift+17]+0.03309496*Close[shift+18]+0.03490921*Close[shift+19] 
                +0.03651145*Close[shift+20]+0.03788045*Close[shift+21]+0.03899804*Close[shift+22]+0.03984915*Close[shift+23] 
                +0.04042329*Close[shift+24]+0.04071263*Close[shift+25]+0.04071263*Close[shift+26]+0.04042329*Close[shift+27] 
                +0.03984915*Close[shift+28]+0.03899804*Close[shift+29]+0.03788045*Close[shift+30]+0.03651145*Close[shift+31] 
                +0.03490921*Close[shift+32]+0.03309496*Close[shift+33]+0.03109071*Close[shift+34]+0.02892446*Close[shift+35] 
                +0.02662203*Close[shift+36]+0.02421320*Close[shift+37]+0.02172747*Close[shift+38]+0.01919533*Close[shift+39] 
                +0.01664635*Close[shift+40]+0.01411056*Close[shift+41]+0.01161720*Close[shift+42]+0.00919334*Close[shift+43] 
                +0.00686394*Close[shift+44]+0.00465269*Close[shift+45]+0.00258172*Close[shift+46]+0.00066887*Close[shift+47] 
                -0.00107121*Close[shift+48]-0.00262594*Close[shift+49]-0.00398417*Close[shift+50]-0.00514293*Close[shift+51] 
                -0.00609634*Close[shift+52]-0.00684602*Close[shift+53]-0.00739452*Close[shift+54]-0.00774847*Close[shift+55] 
                -0.00791630*Close[shift+56]-0.00790940*Close[shift+57]-0.00774085*Close[shift+58]-0.00742482*Close[shift+59] 
                -0.00697718*Close[shift+60]-0.00641613*Close[shift+61]-0.00576108*Close[shift+62]-0.00502957*Close[shift+63] 
                -0.00423873*Close[shift+64]-0.00340812*Close[shift+65]-0.00255923*Close[shift+66]-0.00170217*Close[shift+67] 
                -0.00085902*Close[shift+68]-0.00004113*Close[shift+69]+0.00073700*Close[shift+70]+0.00146422*Close[shift+71] 
                +0.00213007*Close[shift+72]+0.00272649*Close[shift+73]+0.00324752*Close[shift+74]+0.00368922*Close[shift+75] 
                +0.00405000*Close[shift+76]+0.00433024*Close[shift+77]+0.00453068*Close[shift+78]+0.00465046*Close[shift+79] 
                +0.00469058*Close[shift+80]+0.00466041*Close[shift+81]+0.00457855*Close[shift+82]+0.00442491*Close[shift+83] 
                +0.00423019*Close[shift+84]+0.00399201*Close[shift+85]+0.00372169*Close[shift+86]+0.00342736*Close[shift+87] 
                +0.00311822*Close[shift+88]+0.00280309*Close[shift+89]+0.00249088*Close[shift+90]+0.00219089*Close[shift+91] 
                +0.00191283*Close[shift+92]+0.00166683*Close[shift+93]+0.00146419*Close[shift+94]+0.00131867*Close[shift+95] 
                +0.00124645*Close[shift+96]+0.00126836*Close[shift+97]-0.00401854*Close[shift+98]);break;//PCCI-RSTL
                
    case 33: a1 = Close[shift] -  
                (0.36423990*Close[shift+0]+0.33441085*Close[shift+1]+0.25372851*Close[shift+2]+0.14548806*Close[shift+3]
                +0.03934469*Close[shift+4]-0.03871426*Close[shift+5]-0.07451349*Close[shift+6]-0.06903411*Close[shift+7]
                -0.03611022*Close[shift+8]+0.00422528*Close[shift+9]+0.03382809*Close[shift+10]+0.04267885*Close[shift+11]
                +0.03120441*Close[shift+12]+0.00816037*Close[shift+13]-0.01442877*Close[shift+14]-0.02678947*Close[shift+15]
                -0.02525534*Close[shift+16]-0.01272910*Close[shift+17]+0.00350063*Close[shift+18]+0.01565175*Close[shift+19]
                +0.01895659*Close[shift+20]+0.01328613*Close[shift+21]+0.00252297*Close[shift+22]-0.00775517*Close[shift+23]
                -0.01301467*Close[shift+24]-0.01164808*Close[shift+25]-0.00527241*Close[shift+26]+0.00248750*Close[shift+27]
                +0.00793380*Close[shift+28]+0.00897632*Close[shift+29]+0.00583939*Close[shift+30]+0.00059669*Close[shift+31]
                -0.00405186*Close[shift+32]-0.00610944*Close[shift+33]-0.00509042*Close[shift+34]-0.00198138*Close[shift+35]
                +0.00144873*Close[shift+36]+0.00373774*Close[shift+37]+0.01047723*Close[shift+38]-0.00022625*Close[shift+39]);break;//PCCI-RBCI(1)
                   
    case 34: a1 = Close[shift] -  
                (0.08269258*Close[shift+0]+0.08210489*Close[shift+1]+0.08093874*Close[shift+2]+0.07921003*Close[shift+3]
                +0.07694005*Close[shift+4]+0.07415944*Close[shift+5]+0.07090508*Close[shift+6]+0.06722010*Close[shift+7]
                +0.06314921*Close[shift+8]+0.05874928*Close[shift+9]+0.05407277*Close[shift+10]+0.04918011*Close[shift+11]
                +0.04413127*Close[shift+12]+0.03898817*Close[shift+13]+0.03381087*Close[shift+14]+0.02866037*Close[shift+15]
                +0.02359602*Close[shift+16]+0.01867285*Close[shift+17]+0.01394154*Close[shift+18]+0.00945020*Close[shift+19]
                +0.00524380*Close[shift+20]+0.00135856*Close[shift+21]-0.00217576*Close[shift+22]-0.00533362*Close[shift+23]
                -0.00809235*Close[shift+24]-0.01044596*Close[shift+25]-0.01238246*Close[shift+26]-0.01390515*Close[shift+27]
                -0.01501922*Close[shift+28]-0.01573813*Close[shift+29]-0.01607903*Close[shift+30]-0.01606501*Close[shift+31]
                -0.01572265*Close[shift+32]-0.01508076*Close[shift+33]-0.01417155*Close[shift+34]-0.01303199*Close[shift+35]
                -0.01170149*Close[shift+36]-0.01021570*Close[shift+37]-0.00860941*Close[shift+38]-0.00692232*Close[shift+39]
                -0.00519812*Close[shift+40]-0.00345733*Close[shift+41]-0.00174477*Close[shift+42]-0.00008354*Close[shift+43]
                +0.00149695*Close[shift+44]+0.00297402*Close[shift+45]+0.00432644*Close[shift+46]+0.00553786*Close[shift+47]
                +0.00659613*Close[shift+48]+0.00749328*Close[shift+49]+0.00822608*Close[shift+50]+0.00879528*Close[shift+51]
                +0.00920238*Close[shift+52]+0.00944568*Close[shift+53]+0.00952717*Close[shift+54]+0.00946588*Close[shift+55]
                +0.00929962*Close[shift+56]+0.00898757*Close[shift+57]+0.00859207*Close[shift+58]+0.00810829*Close[shift+59]
                +0.00755924*Close[shift+60]+0.00696141*Close[shift+61]+0.00633350*Close[shift+62]+0.00569343*Close[shift+63]
                +0.00505929*Close[shift+64]+0.00444999*Close[shift+65]+0.00388521*Close[shift+66]+0.00338555*Close[shift+67]
                +0.00297397*Close[shift+68]+0.00267839*Close[shift+69]+0.00253170*Close[shift+70]+0.00257620*Close[shift+71]
                -0.00816217*Close[shift+72]);break;//PCCI-RBCI(2)              
                
    case 35: a1 = (0.4360409450*Close[shift+0]+0.3658689069*Close[shift+1]+0.2460452079*Close[shift+2]+0.1104506886*Close[shift+3]
                -0.0054034585*Close[shift+4]-0.0760367731*Close[shift+5]-0.0933058722*Close[shift+6]-0.0670110374*Close[shift+7]
                -0.0190795053*Close[shift+8]+0.0259609206*Close[shift+9]+0.0502044896*Close[shift+10]+0.0477818607*Close[shift+11]
                +0.0249252327*Close[shift+12]-0.0047706151*Close[shift+13]-0.0272432537*Close[shift+14]-0.0338917071*Close[shift+15]
                -0.0244141482*Close[shift+16]-0.0055774838*Close[shift+17]+0.0128149838*Close[shift+18]+0.0226522218*Close[shift+19]
                +0.0208778257*Close[shift+20]+0.0100299086*Close[shift+21]-0.0036771622*Close[shift+22]-0.0136744850*Close[shift+23]
                -0.0160483392*Close[shift+24]-0.0108597376*Close[shift+25]-0.0016060704*Close[shift+26]+0.0069480557*Close[shift+27]
                +0.0110573605*Close[shift+28]+0.0095711419*Close[shift+29]+0.0040444064*Close[shift+30]-0.0023824623*Close[shift+31]
                -0.0067093714*Close[shift+32]-0.0072003400*Close[shift+33]-0.0047717710*Close[shift+34]+0.0005541115*Close[shift+35]
                +0.0007860160*Close[shift+36]+0.0130129076*Close[shift+37]+0.0040364019*Close[shift+38])-    
                  (0.0982862174*Close[shift+0]+0.0975682269*Close[shift+1]+0.0961401078*Close[shift+2]+0.0940230544*Close[shift+3] 
                +0.0912437090*Close[shift+4]+0.0878391006*Close[shift+5]+0.0838544303*Close[shift+6]+0.0793406350*Close[shift+7] 
                +0.0743569346*Close[shift+8]+0.0689666682*Close[shift+9]+0.0632381578*Close[shift+10]+0.0572428925*Close[shift+11] 
                +0.0510534242*Close[shift+12]+0.0447468229*Close[shift+13]+0.0383959950*Close[shift+14]+0.0320735368*Close[shift+15] 
                +0.0258537721*Close[shift+16]+0.0198005183*Close[shift+17]+0.0139807863*Close[shift+18]+0.0084512448*Close[shift+19] 
                +0.0032639979*Close[shift+20]-0.0015350359*Close[shift+21]-0.0059060082*Close[shift+22]-0.0098190256*Close[shift+23] 
                -0.0132507215*Close[shift+24]-0.0161875265*Close[shift+25]-0.0186164872*Close[shift+26]-0.0205446727*Close[shift+27] 
                -0.0219739146*Close[shift+28]-0.0229204861*Close[shift+29]-0.0234080863*Close[shift+30]-0.0234566315*Close[shift+31] 
                -0.0231017777*Close[shift+32]-0.0223796900*Close[shift+33]-0.0213300463*Close[shift+34]-0.0199924534*Close[shift+35] 
                -0.0184126992*Close[shift+36]-0.0166377699*Close[shift+37]-0.0147139428*Close[shift+38]-0.0126796776*Close[shift+39] 
                -0.0105938331*Close[shift+40]-0.0084736770*Close[shift+41]-0.0063841850*Close[shift+42]-0.0043466731*Close[shift+43] 
                -0.0023956944*Close[shift+44]-0.0005535180*Close[shift+45]+0.0011421469*Close[shift+46]+0.0026845693*Close[shift+47] 
                +0.0040471369*Close[shift+48]+0.0052380201*Close[shift+49]+0.0062194591*Close[shift+50]+0.0070340085*Close[shift+51] 
                +0.0076266453*Close[shift+52]+0.0080376628*Close[shift+53]+0.0083037666*Close[shift+54]+0.0083694798*Close[shift+55] 
                +0.0082901022*Close[shift+56]+0.0080741359*Close[shift+57]+0.0077543820*Close[shift+58]+0.0073260526*Close[shift+59] 
                +0.0068163569*Close[shift+60]+0.0062325477*Close[shift+61]+0.0056078229*Close[shift+62]+0.0049516078*Close[shift+63] 
                +0.0161380976*Close[shift+64]);break;//FATL-SATL
    
    case 36: a1 = (0.4360409450*Close[shift+0]+0.3658689069*Close[shift+1]+0.2460452079*Close[shift+2]+0.1104506886*Close[shift+3]
                -0.0054034585*Close[shift+4]-0.0760367731*Close[shift+5]-0.0933058722*Close[shift+6]-0.0670110374*Close[shift+7]
                -0.0190795053*Close[shift+8]+0.0259609206*Close[shift+9]+0.0502044896*Close[shift+10]+0.0477818607*Close[shift+11]
                +0.0249252327*Close[shift+12]-0.0047706151*Close[shift+13]-0.0272432537*Close[shift+14]-0.0338917071*Close[shift+15]
                -0.0244141482*Close[shift+16]-0.0055774838*Close[shift+17]+0.0128149838*Close[shift+18]+0.0226522218*Close[shift+19]
                +0.0208778257*Close[shift+20]+0.0100299086*Close[shift+21]-0.0036771622*Close[shift+22]-0.0136744850*Close[shift+23]
                -0.0160483392*Close[shift+24]-0.0108597376*Close[shift+25]-0.0016060704*Close[shift+26]+0.0069480557*Close[shift+27]
                +0.0110573605*Close[shift+28]+0.0095711419*Close[shift+29]+0.0040444064*Close[shift+30]-0.0023824623*Close[shift+31]
                -0.0067093714*Close[shift+32]-0.0072003400*Close[shift+33]-0.0047717710*Close[shift+34]+0.0005541115*Close[shift+35]
                +0.0007860160*Close[shift+36]+0.0130129076*Close[shift+37]+0.0040364019*Close[shift+38])-
                  (-0.0025097319*Close[shift+0]+0.0513007762*Close[shift+1]+0.1142800493*Close[shift+2]+0.1699342860*Close[shift+3] 
                +0.2025269304*Close[shift+4]+0.2025269304*Close[shift+5]+0.1699342860*Close[shift+6]+0.1142800493*Close[shift+7] 
                +0.0513007762*Close[shift+8]-0.0025097319*Close[shift+9]-0.0353166244*Close[shift+10]-0.0433375629*Close[shift+11] 
                -0.0311244617*Close[shift+12]-0.0088618137*Close[shift+13]+0.0120580088*Close[shift+14]+0.0233183633*Close[shift+15] 
                +0.0221931304*Close[shift+16]+0.0115769653*Close[shift+17]-0.0022157966*Close[shift+18]-0.0126536111*Close[shift+19] 
                -0.0157416029*Close[shift+20]-0.0113395830*Close[shift+21]-0.0025905610*Close[shift+22]+0.0059521459*Close[shift+23] 
                +0.0105212252*Close[shift+24]+0.0096970755*Close[shift+25]+0.0046585685*Close[shift+26]-0.0017079230*Close[shift+27] 
                -0.0063513565*Close[shift+28]-0.0074539350*Close[shift+29]-0.0050439973*Close[shift+30]-0.0007459678*Close[shift+31] 
                +0.0032271474*Close[shift+32]+0.0051357867*Close[shift+33]+0.0044454862*Close[shift+34]+0.0018784961*Close[shift+35] 
                -0.0011065767*Close[shift+36]-0.0031162862*Close[shift+37]-0.0033443253*Close[shift+38]-0.0022163335*Close[shift+39] 
                +0.0002573669*Close[shift+40]+0.0003650790*Close[shift+41]+0.0060440751*Close[shift+42]+0.0018747783*Close[shift+43]);break;//FTLM
    
     case 37: a1 = (0.0982862174*Close[shift+0]+0.0975682269*Close[shift+1]+0.0961401078*Close[shift+2]+0.0940230544*Close[shift+3] 
                +0.0912437090*Close[shift+4]+0.0878391006*Close[shift+5]+0.0838544303*Close[shift+6]+0.0793406350*Close[shift+7] 
                +0.0743569346*Close[shift+8]+0.0689666682*Close[shift+9]+0.0632381578*Close[shift+10]+0.0572428925*Close[shift+11] 
                +0.0510534242*Close[shift+12]+0.0447468229*Close[shift+13]+0.0383959950*Close[shift+14]+0.0320735368*Close[shift+15] 
                +0.0258537721*Close[shift+16]+0.0198005183*Close[shift+17]+0.0139807863*Close[shift+18]+0.0084512448*Close[shift+19] 
                +0.0032639979*Close[shift+20]-0.0015350359*Close[shift+21]-0.0059060082*Close[shift+22]-0.0098190256*Close[shift+23] 
                -0.0132507215*Close[shift+24]-0.0161875265*Close[shift+25]-0.0186164872*Close[shift+26]-0.0205446727*Close[shift+27] 
                -0.0219739146*Close[shift+28]-0.0229204861*Close[shift+29]-0.0234080863*Close[shift+30]-0.0234566315*Close[shift+31] 
                -0.0231017777*Close[shift+32]-0.0223796900*Close[shift+33]-0.0213300463*Close[shift+34]-0.0199924534*Close[shift+35] 
                -0.0184126992*Close[shift+36]-0.0166377699*Close[shift+37]-0.0147139428*Close[shift+38]-0.0126796776*Close[shift+39] 
                -0.0105938331*Close[shift+40]-0.0084736770*Close[shift+41]-0.0063841850*Close[shift+42]-0.0043466731*Close[shift+43] 
                -0.0023956944*Close[shift+44]-0.0005535180*Close[shift+45]+0.0011421469*Close[shift+46]+0.0026845693*Close[shift+47] 
                +0.0040471369*Close[shift+48]+0.0052380201*Close[shift+49]+0.0062194591*Close[shift+50]+0.0070340085*Close[shift+51] 
                +0.0076266453*Close[shift+52]+0.0080376628*Close[shift+53]+0.0083037666*Close[shift+54]+0.0083694798*Close[shift+55] 
                +0.0082901022*Close[shift+56]+0.0080741359*Close[shift+57]+0.0077543820*Close[shift+58]+0.0073260526*Close[shift+59] 
                +0.0068163569*Close[shift+60]+0.0062325477*Close[shift+61]+0.0056078229*Close[shift+62]+0.0049516078*Close[shift+63] 
                +0.0161380976*Close[shift+64])-
                    (-0.00514293*Close[shift+0]-0.00398417*Close[shift+1]-0.00262594*Close[shift+2]-0.00107121*Close[shift+3] 
                +0.00066887*Close[shift+4]+0.00258172*Close[shift+5]+0.00465269*Close[shift+6]+0.00686394*Close[shift+7] 
                +0.00919334*Close[shift+8]+0.01161720*Close[shift+9]+0.01411056*Close[shift+10]+0.01664635*Close[shift+11] 
                +0.01919533*Close[shift+12]+0.02172747*Close[shift+13]+0.02421320*Close[shift+14]+0.02662203*Close[shift+15] 
                +0.02892446*Close[shift+16]+0.03109071*Close[shift+17]+0.03309496*Close[shift+18]+0.03490921*Close[shift+19] 
                +0.03651145*Close[shift+20]+0.03788045*Close[shift+21]+0.03899804*Close[shift+22]+0.03984915*Close[shift+23] 
                +0.04042329*Close[shift+24]+0.04071263*Close[shift+25]+0.04071263*Close[shift+26]+0.04042329*Close[shift+27] 
                +0.03984915*Close[shift+28]+0.03899804*Close[shift+29]+0.03788045*Close[shift+30]+0.03651145*Close[shift+31] 
                +0.03490921*Close[shift+32]+0.03309496*Close[shift+33]+0.03109071*Close[shift+34]+0.02892446*Close[shift+35] 
                +0.02662203*Close[shift+36]+0.02421320*Close[shift+37]+0.02172747*Close[shift+38]+0.01919533*Close[shift+39] 
                +0.01664635*Close[shift+40]+0.01411056*Close[shift+41]+0.01161720*Close[shift+42]+0.00919334*Close[shift+43] 
                +0.00686394*Close[shift+44]+0.00465269*Close[shift+45]+0.00258172*Close[shift+46]+0.00066887*Close[shift+47] 
                -0.00107121*Close[shift+48]-0.00262594*Close[shift+49]-0.00398417*Close[shift+50]-0.00514293*Close[shift+51] 
                -0.00609634*Close[shift+52]-0.00684602*Close[shift+53]-0.00739452*Close[shift+54]-0.00774847*Close[shift+55] 
                -0.00791630*Close[shift+56]-0.00790940*Close[shift+57]-0.00774085*Close[shift+58]-0.00742482*Close[shift+59] 
                -0.00697718*Close[shift+60]-0.00641613*Close[shift+61]-0.00576108*Close[shift+62]-0.00502957*Close[shift+63] 
                -0.00423873*Close[shift+64]-0.00340812*Close[shift+65]-0.00255923*Close[shift+66]-0.00170217*Close[shift+67] 
                -0.00085902*Close[shift+68]-0.00004113*Close[shift+69]+0.00073700*Close[shift+70]+0.00146422*Close[shift+71] 
                +0.00213007*Close[shift+72]+0.00272649*Close[shift+73]+0.00324752*Close[shift+74]+0.00368922*Close[shift+75] 
                +0.00405000*Close[shift+76]+0.00433024*Close[shift+77]+0.00453068*Close[shift+78]+0.00465046*Close[shift+79] 
                +0.00469058*Close[shift+80]+0.00466041*Close[shift+81]+0.00457855*Close[shift+82]+0.00442491*Close[shift+83] 
                +0.00423019*Close[shift+84]+0.00399201*Close[shift+85]+0.00372169*Close[shift+86]+0.00342736*Close[shift+87] 
                +0.00311822*Close[shift+88]+0.00280309*Close[shift+89]+0.00249088*Close[shift+90]+0.00219089*Close[shift+91] 
                +0.00191283*Close[shift+92]+0.00166683*Close[shift+93]+0.00146419*Close[shift+94]+0.00131867*Close[shift+95] 
                +0.00124645*Close[shift+96]+0.00126836*Close[shift+97]-0.00401854*Close[shift+98]);break;//STLM 
       
     case 38: a1 = (0.36423990*Close[shift+0]+0.33441085*Close[shift+1]+0.25372851*Close[shift+2]+0.14548806*Close[shift+3]
                +0.03934469*Close[shift+4]-0.03871426*Close[shift+5]-0.07451349*Close[shift+6]-0.06903411*Close[shift+7]
                -0.03611022*Close[shift+8]+0.00422528*Close[shift+9]+0.03382809*Close[shift+10]+0.04267885*Close[shift+11]
                +0.03120441*Close[shift+12]+0.00816037*Close[shift+13]-0.01442877*Close[shift+14]-0.02678947*Close[shift+15]
                -0.02525534*Close[shift+16]-0.01272910*Close[shift+17]+0.00350063*Close[shift+18]+0.01565175*Close[shift+19]
                +0.01895659*Close[shift+20]+0.01328613*Close[shift+21]+0.00252297*Close[shift+22]-0.00775517*Close[shift+23]
                -0.01301467*Close[shift+24]-0.01164808*Close[shift+25]-0.00527241*Close[shift+26]+0.00248750*Close[shift+27]
                +0.00793380*Close[shift+28]+0.00897632*Close[shift+29]+0.00583939*Close[shift+30]+0.00059669*Close[shift+31]
                -0.00405186*Close[shift+32]-0.00610944*Close[shift+33]-0.00509042*Close[shift+34]-0.00198138*Close[shift+35]
                +0.00144873*Close[shift+36]+0.00373774*Close[shift+37]+0.01047723*Close[shift+38]-0.00022625*Close[shift+39])-
                   (0.08269258*Close[shift+0]+0.08210489*Close[shift+1]+0.08093874*Close[shift+2]+0.07921003*Close[shift+3]
                +0.07694005*Close[shift+4]+0.07415944*Close[shift+5]+0.07090508*Close[shift+6]+0.06722010*Close[shift+7]
                +0.06314921*Close[shift+8]+0.05874928*Close[shift+9]+0.05407277*Close[shift+10]+0.04918011*Close[shift+11]
                +0.04413127*Close[shift+12]+0.03898817*Close[shift+13]+0.03381087*Close[shift+14]+0.02866037*Close[shift+15]
                +0.02359602*Close[shift+16]+0.01867285*Close[shift+17]+0.01394154*Close[shift+18]+0.00945020*Close[shift+19]
                +0.00524380*Close[shift+20]+0.00135856*Close[shift+21]-0.00217576*Close[shift+22]-0.00533362*Close[shift+23]
                -0.00809235*Close[shift+24]-0.01044596*Close[shift+25]-0.01238246*Close[shift+26]-0.01390515*Close[shift+27]
                -0.01501922*Close[shift+28]-0.01573813*Close[shift+29]-0.01607903*Close[shift+30]-0.01606501*Close[shift+31]
                -0.01572265*Close[shift+32]-0.01508076*Close[shift+33]-0.01417155*Close[shift+34]-0.01303199*Close[shift+35]
                -0.01170149*Close[shift+36]-0.01021570*Close[shift+37]-0.00860941*Close[shift+38]-0.00692232*Close[shift+39]
                -0.00519812*Close[shift+40]-0.00345733*Close[shift+41]-0.00174477*Close[shift+42]-0.00008354*Close[shift+43]
                +0.00149695*Close[shift+44]+0.00297402*Close[shift+45]+0.00432644*Close[shift+46]+0.00553786*Close[shift+47]
                +0.00659613*Close[shift+48]+0.00749328*Close[shift+49]+0.00822608*Close[shift+50]+0.00879528*Close[shift+51]
                +0.00920238*Close[shift+52]+0.00944568*Close[shift+53]+0.00952717*Close[shift+54]+0.00946588*Close[shift+55]
                +0.00929962*Close[shift+56]+0.00898757*Close[shift+57]+0.00859207*Close[shift+58]+0.00810829*Close[shift+59]
                +0.00755924*Close[shift+60]+0.00696141*Close[shift+61]+0.00633350*Close[shift+62]+0.00569343*Close[shift+63]
                +0.00505929*Close[shift+64]+0.00444999*Close[shift+65]+0.00388521*Close[shift+66]+0.00338555*Close[shift+67]
                +0.00297397*Close[shift+68]+0.00267839*Close[shift+69]+0.00253170*Close[shift+70]+0.00257620*Close[shift+71]
                -0.00816217*Close[shift+72]);break;//RBCI   
    }
    } 
     
      series=a1;
      if (fF0 < 61)
        {
         fF0= fF0 + 1;
         buffer[fF0]=series;
        } //{ main cycle } 
      if (fF0 > 30)
        {
         if (Len < 1.0000000002)
           {
            f80=0.0000000001; //{1.0e-10} 
           }
         else
           {
            f80=(Len - 1)/2.0;
           }
         if (phase < -100)
           {
            f10=0.5;
           }
         else
           {
            if (phase > 100)
              {
               f10=2.5;
              }
            else
              {
               f10=phase/100 + 1.5;
              }
           }
         v1=MathLog(MathSqrt(f80));
         v2=v1;
         if (v1/MathLog(2.0) + 2.0 < 0.0)
           {
            v3=0;
           }
         else
           {
            v3=v2/MathLog(2.0) + 2.0;
           }
         f98=v3;
//----
         if (0.5<=f98 - 2.0)
           {
            f88=f98 - 2.0;
           }
         else
           {
            f88=0.5;
           }
         f78=MathSqrt(f80) * f98;
         f90=f78/(f78 + 1.0);
         f80=f80 * 0.9;
         f50=f80/(f80 + 2.0);
//----
         if (f0!=0)
           {
            f0=0;
            v5=0;
            for( ii=1;ii <=29;ii++)
              {
               if (buffer[ii+1]!=buffer[ii])
                 {
                  v5=1.0;
                 }
              }
            fD8=v5*30.0;
            if (fD8==0)
              {
               f38=series;
              }
            else
              {
               f38=buffer[1];
              }
            f18=f38;
            if (fD8 > 29)
               fD8=29;
           }
         else
            fD8=0;
//----
         for( ii=fD8;ii>=0;ii-- )
           { //{ another bigcycle...} 
            value2=31-ii;
            if (ii==0)
              {
               f8=series;
              }
            else
              {
               f8=buffer[value2];
              }
            f28=f8 - f18;
            f48=f8 - f38;
            if (MathAbs(f28) > MathAbs(f48))
              {
               v2=MathAbs(f28);
              }
            else
              {
               v2=MathAbs(f48);
              }
            fA0=v2;
            vv=fA0 + 0.0000000001; //{1.0e-10;} 
//----
            if (s48<=1)
              {
               s48=127;
              }
            else
              {
               s48=s48 - 1;
              }
            if (s50<=1)
              {
               s50=10;
              }
            else
              {
               s50=s50 - 1;
              }
            if (s70 < 128)
               s70=s70 + 1;
            s8=s8 + vv - ring2[s50];
            ring2[s50]=vv;
            if (s70 > 10)
              {
               s20=s8/10;
              }
            else
               s20=s8/s70;
//----
            if (s70 > 127)
              {
               s10=ring1[s48];
               ring1[s48]=s20;
               s68=64;
               s58=s68;
               while(s68 > 1)
                 {
                  if (list[s58] < s10)
                    {
                     s68=s68 *0.5;
                     s58=s58 + s68;
                    }
                  else
                     if (list[s58]<=s10)
                       {
                        s68=1;
                       }
                     else
                       {
                        s68=s68 *0.5;
                        s58=s58 - s68;
                       }
                 }
              }
            else
              {
               ring1[s48]=s20;
               if (s28 + s30 > 127)
                 {
                  s30=s30 - 1;
                  s58=s30;
                 }
               else
                 {
                  s28=s28 + 1;
                  s58=s28;
                 }
               if (s28 > 96)
                 {
                  s38=96;
                 }
               else
                  s38=s28;
               if (s30 < 32)
                 {
                  s40=32;
                 }
               else
                  s40=s30;
              }
//----
            s68=64;
            s60=s68;
            while(s68 > 1)
              {
               if (list[s60]>=s20)
                 {
                  if (list[s60 - 1]<=s20)
                    {
                     s68=1;
                    }
                  else
                    {
                     s68=s68 *0.5;
                     s60=s60 - s68;
                    }
                 }
               else
                 {
                  s68=s68 *0.5;
                  s60=s60 + s68;
                 }
               if ((s60==127) && (s20 > list[127]))
                  s60=128;
              }

            if (s70 > 127)
              {
               if (s58>=s60)
                 {
                  if ((s38 + 1 > s60) && (s40 - 1 < s60))
                    {
                     s18=s18 + s20;
                    }
                  else
                     if ((s40 > s60) && (s40 - 1 < s58))
                        s18=s18 + list[s40 - 1];
                 }
               else
                  if (s40>=s60)
                    {
                     if ((s38 + 1 < s60) && (s38 + 1 > s58))
                        s18=s18 + list[s38 + 1];
                    }
                  else
                     if (s38 + 2 > s60)
                       {
                        s18=s18 + s20;
                       }
                     else
                        if ((s38 + 1 < s60) && (s38 + 1 > s58))
                           s18=s18 + list[s38 + 1];

               if (s58 > s60)
                 {
                  if ((s40 - 1 < s58) && (s38 + 1 > s58))
                    {
                     s18=s18 - list[s58];
                    }
                  else
                     if ((s38 < s58) && (s38 + 1 > s60))
                        s18=s18 - list[s38];
                 }
               else
                 {
                  if ((s38 + 1 > s58) && (s40 - 1 < s58))
                    {
                     s18=s18 - list[s58];
                    }
                  else
                     if ((s40 > s58) && (s40 < s60))
                        s18=s18 - list[s40];
                 }
              }
            if (s58<=s60)
              {
               if (s58>=s60)
                 {
                  list[s60]=s20;
                 }
               else
                 {
                  for( jj=s58 + 1;jj<=s60 - 1;jj++)
                    {
                     list[jj - 1]=list[jj];
                    }
                  list[s60 - 1]=s20;
                 }
              }
            else
              {
               for( jj=s58 - 1;jj>=s60;jj-- )
                 {
                  list[jj + 1]=list[jj];
                 }
               list[s60]=s20;
              }
            if (s70<=127)
              {
               s18=0;
               for(jj=s40;jj<=s38;jj++)
                 {
                  s18=s18 + list[jj];
                 }
              }
            f60=s18/(s38 - s40 + 1);
            if (fF8 + 1 > 31)
              {
               fF8=31;
              }
            else
               fF8=fF8 + 1;
//----
            if (fF8<=30)
              {
               if (f28 > 0)
                 {
                  f18=f8;
                 }
               else
                  f18=f8 - f28 * f90;
               if (f48 < 0)
                 {
                  f38=f8;
                 }
               else
                  f38=f8 - f48 * f90;
               fB8=series;
//{EasyLanguage does not have "continue" statement} 
               if (fF8!=30)
                 {
                  continue;
                 }
               if (fF8==30)
                 {
                  fC0=series;
                  if (MathCeil(f78)>=1)
                    {
                     v4=MathCeil(f78);
                    }
                  else
                     v4=1;
                  fE8=MathCeil(v4);
                  if (MathFloor(f78)>=1)
                    {
                     v2=MathFloor(f78);
                    }
                  else
                     v2=1;
                  fE0=MathCeil(v2);
                  if (fE8==fE0)
                    {
                     f68=1;
                    }
                  else
                    {
                     v4=fE8 - fE0;
                     f68=(f78 - fE0)/v4;
                    }
                  if (fE0<=29)
                    {
                     v5=fE0;
                    }
                  else
                     v5=29;
                  if (fE8<=29)
                    {
                     v6=fE8;
                    }
                  else
                     v6=29;
                  fA8=(series - buffer[fF0 - v5]) * (1 - f68)/fE0 + (series - buffer[fF0 - v6]) * f68/fE8;
                 }
              }
            else
              {
               if (f98>=MathPow(fA0/f60, f88))
                 {
                  v1=MathPow(fA0/f60, f88);
                 }
               else
                  v1=f98;
               if (v1 < 1)
                 {
                  v2=1;
                 }
               else
                 {
                  if (f98>=MathPow(fA0/f60, f88))
                    {
                     v3=MathPow(fA0/f60, f88);
                    }
                  else
                     v3=f98;
                  v2=v3;
                 }
               f58=v2;
               f70=MathPow(f90, MathSqrt(f58));
               if (f28 > 0)
                 {
                  f18=f8;
                 }
               else
                 {
                  f18=f8 - f28 * f70;
                 }
               if (f48 < 0)
                 {
                  f38=f8;
                 }
               else
                 {
                  f38=f8 - f48 * f70;
                 }
              }
           }
         if (fF8 > 30)
           {
            f30=MathPow(f50, f58);
            fC0=(1 - f30) * series + f30 * fC0;
            fC8=(series - fC0) * (1 - f50) + f50 * fC8;
            fD0=f10 * fC8 + fC0;
            f20=-f30 * 2;
            f40=f30 * f30;
            fB0=f20 + f40 + 1;
            fA8=(fD0 - fB8) * fB0 + f40 * fA8;
            fB8=fB8 + fA8;
           }
         JMA= fB8;
        }
      if (fF0<=30)
        {
         JMA=0;
        }
      j[shift]= JMA;
      jhi[shift]= JMA;
      jlo[shift]= JMA;

      if (j[shift] > j[shift+1])
      {
          jlo[shift] = EMPTY_VALUE;
      }
      else if (j[shift] < j[shift+1]) 
      {
          jhi[shift] = EMPTY_VALUE;
      }
      else if (j[shift] == j[shift+1]) 
      {
          jhi[shift] = EMPTY_VALUE;
          jlo[shift] = EMPTY_VALUE;
      }
//----
      if (shift>0)
        {
         AccountedBars=AccountedBars+1;
        }
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+