//+------------------------------------------------------------------+ //| nmm.mq4 | //| Copyright © 2007, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_buffers 5 #property indicator_separate_window double extmapbuffer1[]; double extmapbuffer2[]; double extmapbuffer3[]; double extmapbuffer4[]; double extmapbuffer5[]; #property indicator_color1 Yellow #property indicator_color2 Yellow #property indicator_color3 White #property indicator_color4 Green #property indicator_color5 Green //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexStyle (0,DRAW_LINE); SetIndexStyle (1,DRAW_LINE); SetIndexStyle (2,DRAW_LINE); SetIndexStyle (3, DRAW_LINE); SetIndexStyle (4, DRAW_LINE); SetIndexStyle (5, DRAW_LINE); SetIndexBuffer (0, extmapbuffer1); SetIndexBuffer (1, extmapbuffer2); SetIndexBuffer (2, extmapbuffer3); SetIndexBuffer (3, extmapbuffer4); SetIndexBuffer (4, extmapbuffer5); string short_name = "NMAmr"; IndicatorShortName (short_name); //---- indicators //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); double t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40; double a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40; double s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,s26,s27,s28,s29,s30,s31,s32,s33,s34,s35,s36,s37,s38,s39,s40; double ave, badif0,badif1,badif2,badif3,badif4,badif5,badif6,badif7,badif8,badif9,badif10,badif11,badif12,badif13,badif14,badif15,badif16,badif17,badif18,badif19,badif20,badif21,badif22,badif23,badif24,badif25,badif26,badif27,badif28,badif29,badif30,badif31,badif32,badif33,badif34,badif35,badif36,badif37,badif38,badif39,badif40; double sum,sum2, ratio, dif0,dif1,dif2,dif3,dif4,dif5,dif6,dif7,dif8,dif9,dif10,dif11,dif12,dif13,dif14,dif15,dif16,dif17,dif18,dif19,dif20,dif21,dif22,dif23,dif24,dif25,dif26,dif27,dif28,dif29,dif30,dif31,dif32,dif33,dif34,dif35,dif36,dif37,dif38,dif39,dif40; double adif0,adif1,adif2,adif3,adif4,adif5,adif6,adif7,adif8,adif9,adif10,adif11,adif12,adif13,adif14,adif15,adif16,adif17,adif18,adif19,adif20,adif21,adif22,adif23,adif24,adif25,adif26,adif27,adif28,adif29,adif30,adif31,adif32,adif33,adif34,adif35,adif36,adif37,adif38,adif39,adif40; int pos = Bars - counted_bars; while (pos>=0) { if (counted_bars<0) return (-1); if (counted_bars>0) counted_bars--; dif0 = MathAbs((MathLog(Close[pos])*100000) - (MathLog(Close [pos+1])*100000)); dif1 = MathAbs((MathLog(Close[pos+1])*100000) - (MathLog(Close [pos+2])*100000)); dif2 = MathAbs((MathLog(Close[pos+2])*100000) - (MathLog(Close [pos+3])*100000)) ; dif3 = MathAbs((MathLog(Close[pos+3])*100000) - (MathLog(Close [pos+4])*100000)) ; dif4 = MathAbs((MathLog(Close[pos+4])*100000) - (MathLog(Close [pos+5])*100000)) ; dif5 = MathAbs((MathLog(Close[pos+5])*100000) - (MathLog(Close [pos+6])*100000)) ; dif6 = MathAbs((MathLog(Close[pos+6])*100000) - (MathLog(Close [pos+7])*100000)) ; dif7 = MathAbs((MathLog(Close[pos+7])*100000) - (MathLog(Close [pos+8])*100000)) ; dif8 = MathAbs((MathLog(Close[pos+8])*100000) - (MathLog(Close [pos+9])*100000)) ; dif9 = MathAbs((MathLog(Close[pos+9])*100000) - (MathLog(Close [pos+10])*100000)) ; dif10 =MathAbs((MathLog(Close[pos+10])*100000) - (MathLog(Close [pos+11])*100000)); dif11 =MathAbs((MathLog(Close[pos+11])*100000) - (MathLog(Close [pos+12])*100000)) ; dif12 =MathAbs((MathLog(Close[pos+12])*100000) - (MathLog(Close [pos+13])*100000)) ; dif14 =MathAbs((MathLog(Close[pos+13])*100000) - (MathLog(Close [pos+14])*100000)) ; dif15 =MathAbs((MathLog(Close[pos+14])*100000) - (MathLog(Close [pos+15])*100000)) ; dif16 =MathAbs((MathLog(Close[pos+15])*100000) - (MathLog(Close [pos+16])*100000)); dif17 =MathAbs((MathLog(Close[pos+16])*100000) - (MathLog(Close [pos+17])*100000)) ; dif18 =MathAbs((MathLog(Close[pos+17])*100000) - (MathLog(Close [pos+18])*100000)) ; dif19 =MathAbs((MathLog(Close[pos+18])*100000) - (MathLog(Close [pos+19])*100000)); dif20 =MathAbs((MathLog(Close[pos+19])*100000) - (MathLog(Close [pos+20])*100000)); adif0 = MathAbs(MathLog(Close[pos])*100000 - MathLog(Close [pos+1])*100000); adif1 = MathAbs(MathLog(Close[pos+1])*100000 - MathLog(Close [pos+2])*100000) * (MathSqrt(2)-MathSqrt(1)); adif2 = MathAbs(MathLog(Close[pos+2])*100000 - MathLog(Close [pos+3])*100000) * (MathSqrt(3)-MathSqrt(2)); adif3 = MathAbs(MathLog(Close[pos+3])*100000 - MathLog(Close [pos+4])*100000) * (MathSqrt(4)-MathSqrt(3)); adif4 = MathAbs(MathLog(Close[pos+4])*100000 - MathLog(Close [pos+5])*100000) * (MathSqrt(5)-MathSqrt(4)); adif5 = MathAbs(MathLog(Close[pos+5])*100000 - MathLog(Close [pos+6])*100000)* (MathSqrt(6)-MathSqrt(5)); adif6 = MathAbs(MathLog(Close[pos+6])*100000 - MathLog(Close [pos+7])*100000) * (MathSqrt(7)-MathSqrt(6)); adif7 = MathAbs(MathLog(Close[pos+7])*100000 - MathLog(Close [pos+8])*100000) * (MathSqrt(8)-MathSqrt(7)); adif8 = MathAbs(MathLog(Close[pos+8])*100000 - MathLog(Close [pos+9])*100000) * (MathSqrt(9)-MathSqrt(8)); adif9 = MathAbs(MathLog(Close[pos+9])*100000 - MathLog(Close [pos+10])*100000) * (MathSqrt(10)-MathSqrt(9)); adif10 =MathAbs (MathLog(Close[pos+10])*100000 - MathLog(Close [pos+11])*100000) * (MathSqrt(11)-MathSqrt(10)); adif11 =MathAbs (MathLog(Close[pos+11])*100000 - MathLog(Close [pos+12])*100000) * (MathSqrt(12)-MathSqrt(11)); adif12 =MathAbs (MathLog(Close[pos+12])*100000 - MathLog(Close [pos+13])*100000) * (MathSqrt(13)-MathSqrt(12)); adif14 =MathAbs (MathLog(Close[pos+13])*100000 - MathLog(Close [pos+14])*100000) * (MathSqrt(14)-MathSqrt(13)); adif15 =MathAbs (MathLog(Close[pos+14])*100000 - MathLog(Close [pos+15])*100000) * (MathSqrt(15)-MathSqrt(14)); adif16 =MathAbs (MathLog(Close[pos+15])*100000 - MathLog(Close [pos+16])*100000) * (MathSqrt(16)-MathSqrt(15)); adif17 =MathAbs (MathLog(Close[pos+16])*100000 - MathLog(Close [pos+17])*100000) * (MathSqrt(17)-MathSqrt(16)); adif18 =MathAbs (MathLog(Close[pos+17])*100000 - MathLog(Close [pos+18])*100000) * (MathSqrt(18)-MathSqrt(17)); adif19 =MathAbs (MathLog(Close[pos+18])*100000 - MathLog(Close [pos+19])*100000) * (MathSqrt(19)-MathSqrt(18)); adif20 =MathAbs (MathLog(Close[pos+19])*100000 - MathLog(Close [pos+20])*100000) * (MathSqrt(20)-MathSqrt(19)); badif1 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+1])*100000) / MathSqrt(1); badif2 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+2])*100000) / MathSqrt(2); badif3 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+3])*100000) / MathSqrt(3); badif4 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+4])*100000) / MathSqrt(4); badif5 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+5])*100000) / MathSqrt(5); badif6 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+6])*100000) / MathSqrt(6); badif7 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+7])*100000) / MathSqrt(7); badif8 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+8])*100000) / MathSqrt(8); badif9 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+9])*100000) / MathSqrt(9); badif10 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+10])*100000) / MathSqrt(10); badif11= (MathLog(Close[pos])*100000 - MathLog(Close [pos+11])*100000) / MathSqrt(11); badif12 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+12])*100000) / MathSqrt(12); badif13 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+13])*100000) / MathSqrt(13); badif14= (MathLog(Close[pos])*100000 - MathLog(Close [pos+14])*100000) / MathSqrt(14); badif15 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+15])*100000) / MathSqrt(15); badif16 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+16])*100000) / MathSqrt(16); badif17 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+17])*100000) / MathSqrt(17); badif18= (MathLog(Close[pos])*100000 - MathLog(Close [pos+18])*100000) / MathSqrt(18); badif19 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+19])*100000) / MathSqrt(19); badif20 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+20])*100000) / MathSqrt(20); badif21 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+21])*100000) / MathSqrt(21); badif22 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+22])*100000) / MathSqrt(22); badif23 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+23])*100000) / MathSqrt(23); badif24 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+24])*100000) / MathSqrt(24); badif26 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+25])*100000) / MathSqrt(25); badif26 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+26])*100000) / MathSqrt(26); badif27 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+27])*100000) / MathSqrt(27); badif28 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+28])*100000) / MathSqrt(28); badif29 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+29])*100000) / MathSqrt(29); badif30 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+30])*100000) / MathSqrt(30); badif31 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+31])*100000) / MathSqrt(31); badif32 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+32])*100000) / MathSqrt(32); badif33 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+33])*100000) / MathSqrt(33); badif34 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+34])*100000) / MathSqrt(34); badif35 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+35])*100000) / MathSqrt(35); badif36 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+36])*100000) / MathSqrt(36); badif37 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+37])*100000) / MathSqrt(37); badif38 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+38])*100000) / MathSqrt(38); badif39 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+39])*100000) / MathSqrt(39); badif40 = (MathLog(Close[pos])*100000 - MathLog(Close [pos+40])*100000) / MathSqrt(40); ave = (badif1+badif2+badif3+badif4+badif5+badif6+badif7+badif8+badif9+badif10+badif11+badif12+badif13+badif14+badif15+badif16+badif17+badif18+badif19+badif20+badif21+badif22+badif23+badif24+badif25+badif26+badif27+badif28+badif29+badif30+badif31+badif32+badif33+badif34+badif35+badif36+badif37+badif38+badif39+badif40)/40; double ratio2, ema=0, ema2=0,ema3=0,ema4=0 ,b,c,d, next,t,x,s,r,v; r= (adif0+adif1+adif2+adif3+adif4+adif5+adif6+adif7+adif8+adif9+adif10+adif11+adif12+adif13+adif14+adif15+adif16+adif17+adif18+adif19+adif20) ; t1 = MathAbs(ave); t2=t1;t3=t2;t4=t3;t5=t4;t6=t7;t7=t8;t8=t9;t9=t10;t10=t11;t11=t12;t12=t13;t13=t14;t14=t15;t15=t16;t17=t18;t18=t19;t19=t20;t21=t22;t22=t23;t23=t24;t24=t25;t26=t27;t27=t28;t28=t29;t29=t30;t30=t31;t31=t32;t32=t33;t33=t34;t34=t35;t35=t36;t36=t37;t37=t38;t38=t39;t39=t40; a1 = (MathSqrt(1)-MathSqrt(0)) * t1; a2 = (MathSqrt(2)-MathSqrt(1)) * t2; a3 = (MathSqrt(3)-MathSqrt(2)) * t3; a4 = (MathSqrt(4)-MathSqrt(3)) * t4; a5 = (MathSqrt(5)-MathSqrt(4)) * t5; a6 = (MathSqrt(6)-MathSqrt(5)) * t6; a7 = (MathSqrt(7)-MathSqrt(6)) * t7; a8 = (MathSqrt(8)-MathSqrt(7)) * t8; a9 = (MathSqrt(9)-MathSqrt(8)) * t9; a10 = (MathSqrt(10)-MathSqrt(9)) * t10; a11 = (MathSqrt(11)-MathSqrt(10)) * t11; a12 = (MathSqrt(12)-MathSqrt(11)) * t12; a13 = (MathSqrt(13)-MathSqrt(12)) * t13; a14 = (MathSqrt(14)-MathSqrt(13)) * t14; a15 = (MathSqrt(15)-MathSqrt(14)) * t15; a16 = (MathSqrt(16)-MathSqrt(15)) * t16; a17 = (MathSqrt(17)-MathSqrt(16)) * t17; a18 = (MathSqrt(18)-MathSqrt(17)) * t18; a19 = (MathSqrt(19)-MathSqrt(18)) * t19; a20 = (MathSqrt(20)-MathSqrt(19)) * t20; a21 = (MathSqrt(21)-MathSqrt(20)) * t21; a22 = (MathSqrt(22)-MathSqrt(21)) * t22; a23 = (MathSqrt(23)-MathSqrt(22)) * t23; a24 = (MathSqrt(24)-MathSqrt(23)) * t24; a25 = (MathSqrt(25)-MathSqrt(24)) * t25; a26 = (MathSqrt(26)-MathSqrt(25)) * t26; a27 = (MathSqrt(27)-MathSqrt(26)) * t27; a28 = (MathSqrt(28)-MathSqrt(27)) * t28; a28 = (MathSqrt(29)-MathSqrt(28)) * t29; a30 = (MathSqrt(30)-MathSqrt(29)) * t30; a31 = (MathSqrt(31)-MathSqrt(30)) * t31; a32 = (MathSqrt(32)-MathSqrt(31)) * t32; a33 = (MathSqrt(33)-MathSqrt(32)) * t33; a34 = (MathSqrt(34)-MathSqrt(33)) * t34; a35 = (MathSqrt(35)-MathSqrt(34)) * t35; a36 = (MathSqrt(36)-MathSqrt(35)) * t36; a37 = (MathSqrt(37)-MathSqrt(36)) * t37; a38 = (MathSqrt(38)-MathSqrt(37)) * t38; a39 = (MathSqrt(39)-MathSqrt(38)) * t39; a40 = (MathSqrt(40)-MathSqrt(39)) * t40; s = MathSqrt(r); v = MathRound(t1+t2+t3+t4+t5+t6+t7+t8+t9+t10+t11+t12+t13+t14+t15+t16+t17+t18+t19+t20+t21+t22+t23+t24+t25+t26+t27+t28+t29+t30+t31+t32+t33+t34+t35+t36+t37+t38+t39+t40); b = MathRound(a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13+a14+a15+a16+a17+a18+a19+a20+a21+a22+a23+a24+a25+a26+a27+a28+a29+a30+a31+a32+a33+a34+a35+a36+a37+a38+a39+a40); if (b==0) ratio2 = ratio2; else ratio2 = (b/v); ema2 = ema2 +(ratio2 * (ave - ema2)); ema4 = ema4 + (ratio2 * ((MathSqrt(r))-ema4)); extmapbuffer1[pos] = ema4; extmapbuffer2[pos]= -ema4; extmapbuffer3[pos] = ema2; extmapbuffer4[pos] = -s; extmapbuffer5[pos] = s; pos--; } //---- //---- return(0); } //+------------------------------------------------------------------+