udc Posted April 7, 2012 Author Report Share Posted April 7, 2012 NMM_MACD_with_Ocn_MAs for MT4 NMM_MACD_with_Ocn_MAs. Again bug in FastNMA TS source code. Now the 3 lines in the chart are calculated like this: magenta: Price -> NMM -> NMA -> (NMM-NMA) yellow: Price -> NMM -> NMA -> (NMM-NMA) -> NMA blue: Price -> NMM -> NMA -> (NMM-NMA) -> FastNMA Original NMM_MACD_with_Ocn_MAs on TradeStation: http://img713.imageshack.us/img713/6022/nmmmacdwithocnmastrades.png NMM_MACD_with_Ocn_MAs on Metatrader: http://img26.imageshack.us/img26/7956/nmmmacdwithocnmasmetatr.png Original size screenshots: http://img194.imageshack.us/img194/6022/nmmmacdwithocnmastrades.png http://img140.imageshack.us/img140/7956/nmmmacdwithocnmasmetatr.png #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Magenta #property indicator_color2 Yellow #property indicator_color3 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMM_MACD_period = 40; extern int NMA_period = 40; extern int NMA_LB_min = 8; double NMM_MACD[]; double NMM_MACD_NMA[]; double NMM_MACD_FastNMA[]; double NMM[]; double NMM_MA[]; int init() { IndicatorShortName("NMM_MACD_with_Ocn_MAs(" + NMM_MACD_period + ", " + NMA_period + ", " + NMA_LB_min + ")"); IndicatorBuffers(5); SetIndexBuffer(0, NMM_MACD); SetIndexLabel(0, "NMM_MACD(" + NMM_MACD_period + ")"); SetIndexBuffer(1, NMM_MACD_NMA); SetIndexLabel(1, "NMM_MACD_NMA(" + NMA_period + ")"); SetIndexBuffer(2, NMM_MACD_FastNMA); SetIndexLabel(2, "NMM_MACD_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); SetIndexBuffer(3, NMM); SetIndexBuffer(4, NMM_MA); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double nmm2, sum, abssum, ratio, nmmnum, maxnmm; if(Bars <= 2*NMM_MACD_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMM_MACD_period) limit = Bars - counted_bars; else limit = Bars - NMM_MACD_period - 1; for(i = limit; i >= 0; i--) { nmm2 = 0; for(ii = 1; ii <= NMM_MACD_period; ii++) nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); NMM[i] = (nmm2 / NMM_MACD_period) * 1000; } for(i = limit; i >= 0; i--) if(i < Bars - 2*NMM_MACD_period - 1) { ratio = 0; sum = (NMM[i] - NMM[i+1]) + (NMM[i+1] - NMM[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMM_MACD_period; ii++) sum += (NMM[i+ii] - NMM[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMM_MACD_period; ii++) sum += MathAbs(NMM[i+ii] - NMM[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_MA[i] = NMM_MA[i+1] + (NMM[i] - NMM_MA[i+1]) * ratio; NMM_MACD[i] = NMM[i] - NMM_MA[i]; } for(i = limit; i >= 0; i--) if(i < Bars - 2*NMM_MACD_period - 1 - NMA_period) { ratio = 0; sum = (NMM_MACD[i] - NMM_MACD[i+1]) + (NMM_MACD[i+1] - NMM_MACD[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMM_MACD[i+ii] - NMM_MACD[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMM_MACD[i+ii] - NMM_MACD[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_MACD_NMA[i] = NMM_MACD_NMA[i+1] + (NMM_MACD[i] - NMM_MACD_NMA[i+1]) * ratio; } for(i = limit; i >= 0; i--) if(i < Bars - 2*NMM_MACD_period - 1 - NMA_period) { maxnmm = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmmnum = (NMM_MACD[i] - NMM_MACD[i+ii]) / MathSqrt(ii); if(MathAbs(nmmnum) > maxnmm) { maxnmm = MathAbs(nmmnum); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMM_MACD[i] - NMM_MACD[i+1]) + (NMM_MACD[i+1] - NMM_MACD[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMM_MACD[i+ii] - NMM_MACD[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMM_MACD[i+ii] - NMM_MACD[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_MACD_FastNMA[i] = NMM_MACD_FastNMA[i+1] + (NMM_MACD[i] - NMM_MACD_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/atG6n9x0 Next one will be NMC. josephR, tradershare, C0UNDE and 6 others 9 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 NMM_ROC for MT4 NMM_ROC - almost missed this one. Should be the last one from the NMM family. Original NMM_ROC on TradeStation: http://img72.imageshack.us/img72/5621/nmmroctradestation.png NMM_ROC on Metatrader: http://img217.imageshack.us/img217/3605/nmmrocmetatrader.png Original size screenshots: http://img18.imageshack.us/img18/5621/nmmroctradestation.png http://img40.imageshack.us/img40/3605/nmmrocmetatrader.png #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Magenta #property indicator_color2 Silver #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMM_ROC_period = 40; extern int NMM_ROC_LB = 3; extern int NMM_ROC_AvgLen = 3; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; double NMM_ROC[]; double SD[]; double NMM[]; double NMM_ROCx[]; int init() { string nmmrocname = "NMM_ROC(" + NMM_ROC_period + ", " + NMM_ROC_LB + ", " + NMM_ROC_AvgLen + ")"; string sdname = "NMM_ROC_SD(" + SD_len + ")"; IndicatorShortName(nmmrocname); IndicatorBuffers(4); SetIndexBuffer(0, NMM_ROC); SetIndexLabel(0, nmmrocname); SetIndexBuffer(1, SD); SetIndexLabel(1, sdname); SetIndexBuffer(2, NMM); SetIndexBuffer(3, NMM_ROCx); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); if(Bars <= NMM_ROC_period + NMM_ROC_LB + NMM_ROC_AvgLen) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMM_ROC_period) limit = Bars - counted_bars; else limit = Bars - NMM_ROC_period - 1; for(i = limit; i >= 0; i--) { double nmm2 = 0; for(ii = 1; ii <= NMM_ROC_period; ii++) nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); NMM[i] = (nmm2 / NMM_ROC_period) * 1000; } for(i = limit; i >= 0; i--) if(i < Bars - NMM_ROC_period - 1 - NMM_ROC_LB) NMM_ROCx[i] = NMM[i] - NMM[i+NMM_ROC_LB]; for(i = limit; i >= 0; i--) if(i < Bars - NMM_ROC_period - 1 - NMM_ROC_LB - NMM_ROC_AvgLen) { double WtdSum = 0; for(ii = 0; ii < NMM_ROC_AvgLen; ii++) WtdSum += (NMM_ROC_AvgLen - ii) * NMM_ROCx[i+ii]; NMM_ROC[i] = WtdSum / ((NMM_ROC_AvgLen + 1) * NMM_ROC_AvgLen * 0.5); } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - NMM_ROC_period - 1 - NMM_ROC_LB - NMM_ROC_AvgLen - SD_len) { if(NMM_ROC[i] == 0) SD[i] = 0; else if(NMM_ROC[i] > 0) SD[i] = iBandsOnArray(NMM_ROC, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMM_ROC[i] < 0) SD[i] = iBandsOnArray(NMM_ROC, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } return(0); } The source code is also available for download here: http://pastebin.com/eZn3fywg mashki, C0UNDE, damo1713005996 and 5 others 8 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 NMC for MT4 Long awaited NMC :) Original NMC on TradeStation: http://img849.imageshack.us/img849/961/nmctradestation.png NMC on Metatrader: http://img341.imageshack.us/img341/1166/nmcmetatrader.png Original size screenshots: http://img252.imageshack.us/img252/961/nmctradestation.png http://img528.imageshack.us/img528/1166/nmcmetatrader.png #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Magenta #property indicator_color2 Silver #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMC_period = 40; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; double NMC[]; double SD[]; int init() { string nmcname = "NMC(" + NMC_period + ")"; string sdname = "NMC_SD(" + SD_len + ")"; IndicatorShortName(nmcname); IndicatorBuffers(2); SetIndexBuffer(0, NMC); SetIndexLabel(0, nmcname); SetIndexBuffer(1, SD); SetIndexLabel(1, sdname); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); if(Bars <= NMC_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMC_period) limit = Bars - counted_bars; else limit = Bars - NMC_period - 1; for(i = limit; i >= 0; i--) { double nmm, nmr, nmm2 = 0, nmr2 = 0, avg, sign; for(ii = 1; ii <= NMC_period; ii++) { nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); nmr2 += (MathLog(Close[i+ii-1]) - MathLog(Close[i+ii])) * (MathSqrt(ii) - MathSqrt(ii-1)); } nmm = (nmm2 / NMC_period) * 1000; nmr = nmr2 * 1000; avg = ((MathAbs(nmm) * nmr) + (MathAbs(nmr) * nmm)) / 2; if(avg > 0) sign = 1; else if(avg < 0) sign = -1; else sign = 0; NMC[i] = sign * MathSqrt(MathAbs(avg)); } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - NMC_period - 1 - SD_len) { if(NMC[i] == 0) SD[i] = 0; else if(NMC[i] > 0) SD[i] = iBandsOnArray(NMC, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMC[i] < 0) SD[i] = iBandsOnArray(NMC, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } return(0); } The source code is also available for download here: http://pastebin.com/mhf0Utpv fawaz79, crodzilla, indo37 and 5 others 8 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 NMC_with_Ocn_MAs for MT4 ..and an older brother NMC_with_Ocn_MAs. Original NMC_with_Ocn_MAs on TradeStation: http://img43.imageshack.us/img43/6556/nmcwithocnmastradestati.png NMC_with_Ocn_MAs on Metatrader: http://img220.imageshack.us/img220/7998/nmcwithocnmasmetatrader.png Original size screenshots: http://img210.imageshack.us/img210/6556/nmcwithocnmastradestati.png http://img822.imageshack.us/img822/7998/nmcwithocnmasmetatrader.png #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Magenta #property indicator_color2 Yellow #property indicator_color3 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMC_period = 40; extern int NMA_period = 40; extern int NMA_LB_min = 8; double NMC[]; double NMC_NMA[]; double NMC_FastNMA[]; int init() { IndicatorShortName("NMC_with_Ocn_MAs(" + NMC_period + ", " + NMA_period + ", " + NMA_LB_min + ")"); IndicatorBuffers(3); SetIndexBuffer(0, NMC); SetIndexLabel(0, "NMC(" + NMC_period + ")"); SetIndexBuffer(1, NMC_NMA); SetIndexLabel(1, "NMC_NMA(" + NMA_period + ")"); SetIndexBuffer(2, NMC_FastNMA); SetIndexLabel(2, "NMC_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double nmm, nmr, nmm2, nmr2, avg, sign, sum, abssum, ratio, nmcnum, maxnmc; if(Bars <= NMC_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMC_period) limit = Bars - counted_bars; else limit = Bars - NMC_period - 1; for(i = limit; i >= 0; i--) { nmm2 = 0; nmr2 = 0; for(ii = 1; ii <= NMC_period; ii++) { nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); nmr2 += (MathLog(Close[i+ii-1]) - MathLog(Close[i+ii])) * (MathSqrt(ii) - MathSqrt(ii-1)); } nmm = (nmm2 / NMC_period) * 1000; nmr = nmr2 * 1000; avg = ((MathAbs(nmm) * nmr) + (MathAbs(nmr) * nmm)) / 2; if(avg > 0) sign = 1; else if(avg < 0) sign = -1; else sign = 0; NMC[i] = sign * MathSqrt(MathAbs(avg)); } for(i = limit; i >= 0; i--) if(i < Bars - NMC_period - 1 - NMA_period) { ratio = 0; sum = (NMC[i] - NMC[i+1]) + (NMC[i+1] - NMC[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMC[i+ii] - NMC[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMC[i+ii] - NMC[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMC_NMA[i] = NMC_NMA[i+1] + (NMC[i] - NMC_NMA[i+1]) * ratio; } for(i = limit; i >= 0; i--) if(i < Bars - NMC_period - 1 - NMA_period) { maxnmc = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmcnum = (NMC[i] - NMC[i+ii]) / MathSqrt(ii); if(MathAbs(nmcnum) > maxnmc) { maxnmc = MathAbs(nmcnum); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMC[i] - NMC[i+1]) + (NMC[i+1] - NMC[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMC[i+ii] - NMC[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMC[i+ii] - NMC[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMC_FastNMA[i] = NMC_FastNMA[i+1] + (NMC[i] - NMC_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/hU8hazhx damo1713005996, crodzilla, indo37 and 4 others 7 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 NMC2 for MT4 NMC2. While NMC is calculated from NMM and NMR, NMC2 is calculated from NMS and either NMM or NMR, so you have two possible choices here. To choose which one you want, set the option "Use_NMR_instead_NMM" either to "true" (for calculation using NMS and NMR) or to "false" (for calculation using NMS and NMM). Which variant was chosen can be then seen in the upper left corner of the indicator window. Original NMC2 on TradeStation: http://img337.imageshack.us/img337/87/nmc2tradestation.png NMC2 on Metatrader: http://img220.imageshack.us/img220/1598/nmc2metatrader.png Original size screenshots: http://img210.imageshack.us/img210/87/nmc2tradestation.png http://img11.imageshack.us/img11/1598/nmc2metatrader.png #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Magenta #property indicator_color2 Silver #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMC2_period = 40; extern bool Use_NMR_instead_NMM = false; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; double NMC2[]; double SD[]; int init() { string whichone = "NMM"; if(Use_NMR_instead_NMM) whichone = "NMR"; string nmc2name = "NMC2(" + NMC2_period + ", using " + whichone + ")"; string sdname = "NMC2_SD(" + SD_len + ")"; IndicatorShortName(nmc2name); IndicatorBuffers(2); SetIndexBuffer(0, NMC2); SetIndexLabel(0, nmc2name); SetIndexBuffer(1, SD); SetIndexLabel(1, sdname); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); if(Bars <= NMC2_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMC2_period) limit = Bars - counted_bars; else limit = Bars - NMC2_period - 1; for(i = limit; i >= 0; i--) { double nms, nmm, nmr, nms2 = 0, nmm2 = 0, nmr2 = 0, whichone, avg, sign; for(ii = 1; ii <= NMC2_period; ii++) { double oLRSlope = 0, SumXY = 0, SumY = 0, SumX, SumXSqr, Divisor; if(ii > 1) { SumX = ii * (ii - 1) * 0.5; SumXSqr = ii * (ii - 1) * (2 * ii - 1) * 1/6; Divisor = (SumX * SumX) - ii * SumXSqr; for(int iii = 0; iii < ii; iii++) { SumXY += iii * MathLog(Close[i+iii]); SumY += MathLog(Close[i+iii]); } oLRSlope = (ii * SumXY - SumX * SumY) / Divisor; } nms2 += oLRSlope * MathSqrt(ii); nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); nmr2 += (MathLog(Close[i+ii-1]) - MathLog(Close[i+ii])) * (MathSqrt(ii) - MathSqrt(ii-1)); } nms = nms2 * 100; nmm = (nmm2 / NMC2_period) * 1000; nmr = nmr2 * 1000; if(Use_NMR_instead_NMM) whichone = nmr; else whichone = nmm; avg = ((MathAbs(nms) * whichone) + (MathAbs(whichone) * nms)) / 2; if(avg > 0) sign = 1; else if(avg < 0) sign = -1; else sign = 0; NMC2[i] = sign * MathSqrt(MathAbs(avg)); } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - NMC2_period - 1 - SD_len) { if(NMC2[i] == 0) SD[i] = 0; else if(NMC2[i] > 0) SD[i] = iBandsOnArray(NMC2, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMC2[i] < 0) SD[i] = iBandsOnArray(NMC2, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } return(0); } The source code is also available for download here: http://pastebin.com/KuTsg81S indo37, damo1713005996, fawaz79 and 3 others 6 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 NMC2_with_Ocn_MAs for MT4 NMC2_with_Ocn_MAs. Original NMC2_with_Ocn_MAs on TradeStation: http://img834.imageshack.us/img834/7189/nmc2withocnmastradestat.png NMC2_with_Ocn_MAs on Metatrader: http://img31.imageshack.us/img31/6079/nmc2withocnmasmetatrade.png Original size screenshots: http://img17.imageshack.us/img17/7189/nmc2withocnmastradestat.png http://img534.imageshack.us/img534/6079/nmc2withocnmasmetatrade.png #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Magenta #property indicator_color2 Yellow #property indicator_color3 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMC2_period = 40; extern bool Use_NMR_instead_NMM = false; extern int NMA_period = 40; extern int NMA_LB_min = 8; double NMC2[]; double NMC2_NMA[]; double NMC2_FastNMA[]; int init() { string whichone = "NMM"; if(Use_NMR_instead_NMM) whichone = "NMR"; IndicatorShortName("NMC2_with_Ocn_MAs(" + NMC2_period + ", using " + whichone + ", " + NMA_period + ", " + NMA_LB_min + ")"); IndicatorBuffers(3); SetIndexBuffer(0, NMC2); SetIndexLabel(0, "NMC2(" + NMC2_period + ", using " + whichone + ")"); SetIndexBuffer(1, NMC2_NMA); SetIndexLabel(1, "NMC2_NMA(" + NMA_period + ")"); SetIndexBuffer(2, NMC2_FastNMA); SetIndexLabel(2, "NMC2_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double nms, nmm, nmr, nms2, nmm2, nmr2, whichone, avg, sign, sum, abssum, ratio, nmc2num, maxnmc2; if(Bars <= NMC2_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMC2_period) limit = Bars - counted_bars; else limit = Bars - NMC2_period - 1; for(i = limit; i >= 0; i--) { nms2 = 0; nmm2 = 0; nmr2 = 0; for(ii = 1; ii <= NMC2_period; ii++) { double oLRSlope = 0, SumXY = 0, SumY = 0, SumX, SumXSqr, Divisor; if(ii > 1) { SumX = ii * (ii - 1) * 0.5; SumXSqr = ii * (ii - 1) * (2 * ii - 1) * 1/6; Divisor = (SumX * SumX) - ii * SumXSqr; for(int iii = 0; iii < ii; iii++) { SumXY += iii * MathLog(Close[i+iii]); SumY += MathLog(Close[i+iii]); } oLRSlope = (ii * SumXY - SumX * SumY) / Divisor; } nms2 += oLRSlope * MathSqrt(ii); nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); nmr2 += (MathLog(Close[i+ii-1]) - MathLog(Close[i+ii])) * (MathSqrt(ii) - MathSqrt(ii-1)); } nms = nms2 * 100; nmm = (nmm2 / NMC2_period) * 1000; nmr = nmr2 * 1000; if(Use_NMR_instead_NMM) whichone = nmr; else whichone = nmm; avg = ((MathAbs(nms) * whichone) + (MathAbs(whichone) * nms)) / 2; if(avg > 0) sign = 1; else if(avg < 0) sign = -1; else sign = 0; NMC2[i] = sign * MathSqrt(MathAbs(avg)); } for(i = limit; i >= 0; i--) if(i < Bars - NMC2_period - 1 - NMA_period) { ratio = 0; sum = (NMC2[i] - NMC2[i+1]) + (NMC2[i+1] - NMC2[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMC2[i+ii] - NMC2[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMC2[i+ii] - NMC2[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMC2_NMA[i] = NMC2_NMA[i+1] + (NMC2[i] - NMC2_NMA[i+1]) * ratio; } for(i = limit; i >= 0; i--) if(i < Bars - NMC2_period - 1 - NMA_period) { maxnmc2 = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmc2num = (NMC2[i] - NMC2[i+ii]) / MathSqrt(ii); if(MathAbs(nmc2num) > maxnmc2) { maxnmc2 = MathAbs(nmc2num); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMC2[i] - NMC2[i+1]) + (NMC2[i+1] - NMC2[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMC2[i+ii] - NMC2[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMC2[i+ii] - NMC2[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMC2_FastNMA[i] = NMC2_FastNMA[i+1] + (NMC2[i] - NMC2_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/F2H6tjXV mashki, C0UNDE, kolikol and 5 others 8 Quote Link to comment Share on other sites More sharing options...
hermes Posted April 8, 2012 Report Share Posted April 8, 2012 Complicated but looks accurate! Hermes Quote Link to comment Share on other sites More sharing options...
bingo_bongoo Posted April 8, 2012 Report Share Posted April 8, 2012 Excellent job !!! My compliments udc Bingo Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 Thanks :) Ok, so what is left from the original Ocean pack is: NDX, NST and NXC. Then there are BTX and STX from the Ocean Plus, those have their logic moved to the external DLL, so I will see if the DLL will work in Metatrader. Also, I was thinking about remaking the so far done Ocean indis into a single version of each, i.e. a single NMA indi with NMA and FastNMA, a single NMC indi with MAs and SDs etc., with each line selectively switchable on/off. It wouldn't bring any new value, it would be just for convenience. Because I noticed on some youtube videos Jim is using for example NMC2 with OcnMAs as well as with SDs at the same time and on top of that there is not only one side of SD but both sides. So I was just thinking I may as well just make a single indi for each algorithm with all possible features built in all together, instead of having 2-3 or even more indi variants for each algo. What do you think, would it be worth the effort? mashki, Alex-622, f451 and 1 other 4 Quote Link to comment Share on other sites More sharing options...
Sixer Posted April 8, 2012 Report Share Posted April 8, 2012 (edited) udc, i have used the "NMC2 with OcnMAs" indicator in the past as the only indicator from the total package for the Tradestation platform. Ecxellent job for all MT users !! Sixer Edited April 8, 2012 by Sixer Quote Link to comment Share on other sites More sharing options...
fawaz79 Posted April 8, 2012 Report Share Posted April 8, 2012 fantastic idea UDC!! It will be so helpful if we can combine the indicators as you said.... you are the best... thanks for the wonderful work Quote Link to comment Share on other sites More sharing options...
Danny Posted April 8, 2012 Report Share Posted April 8, 2012 GREAT effort GREAT programming skill GREAT sharing spirit GREAT THANKS UDC -Danny Quote Link to comment Share on other sites More sharing options...
⭐ dynastic Posted April 8, 2012 Report Share Posted April 8, 2012 (edited) Updated zip file with all udc indicators so far. http://uloz.to/xuoxEEv/ocean-indicators-by-udc-v1-1-zip Also, I was thinking about remaking the so far done Ocean indis into a single version of each, i.e. a single NMA indi with NMA and FastNMA, a single NMC indi with MAs and SDs etc., with each line selectively switchable on/off. It wouldn't bring any new value, it would be just for convenience. Because I noticed on some youtube videos Jim is using for example NMC2 with OcnMAs as well as with SDs at the same time and on top of that there is not only one side of SD but both sides. So I was just thinking I may as well just make a single indi for each algorithm with all possible features built in all together, instead of having 2-3 or even more indi variants for each algo. What do you think, would it be worth the effort? Sounds like a very good idea also. Will make it less confusing with smaller number of mql files :) Edited April 8, 2012 by digian tsar and C0UNDE 2 Quote Link to comment Share on other sites More sharing options...
edmun1388 Posted April 8, 2012 Report Share Posted April 8, 2012 edmun1388 bow to UDC . Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 Ocn_NMC2x for MT4 Ok, so here is a prototype of an NMC2 indicator with all functions incorporated, plus some new features. http://img801.imageshack.us/img801/5536/ocnnmc2x.png First, there is a new feature showing the zero hits using a specified symbol. You can select the symbol from the list: http://img855.imageshack.us/img855/4386/mt4symbols.png Also, you can select the vertical displacement of this symbol. And of course you can turn it off. Second, there is an option to show either a single SD line (showing either upper or lower SD band based on the position of NMC2) as was so far, or you can choose to show both lower and upper SD bands or only one of them. Showing both bands may be useful as can be seen in the screenshot on the right around 5 Apr 09:00. Lastly, you can selective turn on/off the NMA and FastNMA of NMC2. Check it out and tell me whether you can think of any other feature or modification, before I remake all other Ocean indis in the same way. From now on I will also prefix these final version with "Ocn_" string so it is sorted in the Metatrader all together. Original size screenshots: http://img571.imageshack.us/img571/5536/ocnnmc2x.png #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Magenta #property indicator_color2 Lime #property indicator_color3 Silver #property indicator_color4 Silver #property indicator_color5 Yellow #property indicator_color6 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMC2_period = 40; extern bool Use_NMR_instead_NMM = false; extern bool Show_ZH = true; extern double ZH_displacement = 1; extern int ZH_symbol = 115; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; extern bool Show_SD_1line_only = true; extern bool Show_SD_2lines_up = true; extern bool Show_SD_2lines_dn = true; extern int NMA_period = 40; extern int NMA_LB_min = 8; extern bool Show_NMA = true; extern bool Show_FastNMA = true; double NMC2[]; double ZH[]; double SD[]; double SD2[]; double NMC2_NMA[]; double NMC2_FastNMA[]; int init() { string whichone = "NMM"; if(Use_NMR_instead_NMM) whichone = "NMR"; string nmc2name = "NMC2(" + NMC2_period + ", using " + whichone + ")"; IndicatorShortName(nmc2name); IndicatorBuffers(6); SetIndexBuffer(0, NMC2); SetIndexLabel(0, nmc2name); SetIndexBuffer(1, ZH); SetIndexLabel(1, "NMC2_ZH"); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, ZH_symbol); SetIndexBuffer(2, SD); SetIndexBuffer(3, SD2); if(Show_SD_1line_only) { SetIndexLabel(2, "NMC2_SD(" + SD_len + ")"); SetIndexLabel(3, "unused"); } else { if(Show_SD_2lines_up) SetIndexLabel(2, "NMC2_SD_up(" + SD_len + ")"); else SetIndexLabel(2, "unused"); if(Show_SD_2lines_dn) SetIndexLabel(3, "NMC2_SD_dn(" + SD_len + ")"); else SetIndexLabel(3, "unused"); } SetIndexBuffer(4, NMC2_NMA); SetIndexBuffer(5, NMC2_FastNMA); if(Show_NMA) SetIndexLabel(4, "NMC2_NMA(" + NMA_period + ")"); else SetIndexLabel(4, "unused"); if(Show_FastNMA) SetIndexLabel(5, "NMC2_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); else SetIndexLabel(5, "unused"); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double nms, nmm, nmr, nms2, nmm2, nmr2, whichone, avg, sign, sum, abssum, ratio, nmc2num, maxnmc2; if(Bars <= NMC2_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMC2_period) limit = Bars - counted_bars; else limit = Bars - NMC2_period - 1; for(i = limit; i >= 0; i--) { nms2 = 0; nmm2 = 0; nmr2 = 0; for(ii = 1; ii <= NMC2_period; ii++) { double oLRSlope = 0, SumXY = 0, SumY = 0, SumX, SumXSqr, Divisor; if(ii > 1) { SumX = ii * (ii - 1) * 0.5; SumXSqr = ii * (ii - 1) * (2 * ii - 1) * 1/6; Divisor = (SumX * SumX) - ii * SumXSqr; for(int iii = 0; iii < ii; iii++) { SumXY += iii * MathLog(Close[i+iii]); SumY += MathLog(Close[i+iii]); } oLRSlope = (ii * SumXY - SumX * SumY) / Divisor; } nms2 += oLRSlope * MathSqrt(ii); nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); nmr2 += (MathLog(Close[i+ii-1]) - MathLog(Close[i+ii])) * (MathSqrt(ii) - MathSqrt(ii-1)); } nms = nms2 * 100; nmm = (nmm2 / NMC2_period) * 1000; nmr = nmr2 * 1000; if(Use_NMR_instead_NMM) whichone = nmr; else whichone = nmm; avg = ((MathAbs(nms) * whichone) + (MathAbs(whichone) * nms)) / 2; if(avg > 0) sign = 1; else if(avg < 0) sign = -1; else sign = 0; NMC2[i] = sign * MathSqrt(MathAbs(avg)); if(Show_ZH) { if(NMC2[i] == 0) ZH[i] = ZH_displacement; else ZH[i] = EMPTY_VALUE; } } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - NMC2_period - 1 - SD_len) { if(Show_SD_1line_only) { if(NMC2[i] == 0) SD[i] = 0; else if(NMC2[i] > 0) SD[i] = iBandsOnArray(NMC2, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMC2[i] < 0) SD[i] = iBandsOnArray(NMC2, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } else { if(NMC2[i] == 0) { if(Show_SD_2lines_up) SD[i] = 0; if(Show_SD_2lines_dn) SD2[i] = 0; } else { if(Show_SD_2lines_up) SD[i] = iBandsOnArray(NMC2, 0, SD_len, SD_up, 0, MODE_UPPER, i); if(Show_SD_2lines_dn) SD2[i] = iBandsOnArray(NMC2, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } } } if(Show_NMA) for(i = limit; i >= 0; i--) if(i < Bars - NMC2_period - 1 - NMA_period) { ratio = 0; sum = (NMC2[i] - NMC2[i+1]) + (NMC2[i+1] - NMC2[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMC2[i+ii] - NMC2[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMC2[i+ii] - NMC2[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMC2_NMA[i] = NMC2_NMA[i+1] + (NMC2[i] - NMC2_NMA[i+1]) * ratio; } if(Show_FastNMA) for(i = limit; i >= 0; i--) if(i < Bars - NMC2_period - 1 - NMA_period) { maxnmc2 = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmc2num = (NMC2[i] - NMC2[i+ii]) / MathSqrt(ii); if(MathAbs(nmc2num) > maxnmc2) { maxnmc2 = MathAbs(nmc2num); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMC2[i] - NMC2[i+1]) + (NMC2[i+1] - NMC2[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMC2[i+ii] - NMC2[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMC2[i+ii] - NMC2[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMC2_FastNMA[i] = NMC2_FastNMA[i+1] + (NMC2[i] - NMC2_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/VaWnkY31 fawaz79, damo1713005996, tgt123 and 3 others 6 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 Ocn_NMCx for MT4 Similarly as Ocn_NMC2x, here is Ocn_NMCx. #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Magenta #property indicator_color2 Lime #property indicator_color3 Silver #property indicator_color4 Silver #property indicator_color5 Yellow #property indicator_color6 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMC_period = 40; extern bool Show_ZH = true; extern double ZH_displacement = 1; extern int ZH_symbol = 115; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; extern bool Show_SD_1line_only = true; extern bool Show_SD_2lines_up = true; extern bool Show_SD_2lines_dn = true; extern int NMA_period = 40; extern int NMA_LB_min = 8; extern bool Show_NMA = true; extern bool Show_FastNMA = true; double NMC[]; double ZH[]; double SD[]; double SD2[]; double NMC_NMA[]; double NMC_FastNMA[]; int init() { string nmcname = "NMC(" + NMC_period + ")"; IndicatorShortName(nmcname); IndicatorBuffers(6); SetIndexBuffer(0, NMC); SetIndexLabel(0, nmcname); SetIndexBuffer(1, ZH); SetIndexLabel(1, "NMC_ZH"); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, ZH_symbol); SetIndexBuffer(2, SD); SetIndexBuffer(3, SD2); if(Show_SD_1line_only) { SetIndexLabel(2, "NMC_SD(" + SD_len + ")"); SetIndexLabel(3, "unused"); } else { if(Show_SD_2lines_up) SetIndexLabel(2, "NMC_SD_up(" + SD_len + ")"); else SetIndexLabel(2, "unused"); if(Show_SD_2lines_dn) SetIndexLabel(3, "NMC_SD_dn(" + SD_len + ")"); else SetIndexLabel(3, "unused"); } SetIndexBuffer(4, NMC_NMA); SetIndexBuffer(5, NMC_FastNMA); if(Show_NMA) SetIndexLabel(4, "NMC_NMA(" + NMA_period + ")"); else SetIndexLabel(4, "unused"); if(Show_FastNMA) SetIndexLabel(5, "NMC_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); else SetIndexLabel(5, "unused"); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double nmm, nmr, nmm2, nmr2, avg, sign, sum, abssum, ratio, nmcnum, maxnmc; if(Bars <= NMC_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMC_period) limit = Bars - counted_bars; else limit = Bars - NMC_period - 1; for(i = limit; i >= 0; i--) { nmm2 = 0; nmr2 = 0; for(ii = 1; ii <= NMC_period; ii++) { nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); nmr2 += (MathLog(Close[i+ii-1]) - MathLog(Close[i+ii])) * (MathSqrt(ii) - MathSqrt(ii-1)); } nmm = (nmm2 / NMC_period) * 1000; nmr = nmr2 * 1000; avg = ((MathAbs(nmm) * nmr) + (MathAbs(nmr) * nmm)) / 2; if(avg > 0) sign = 1; else if(avg < 0) sign = -1; else sign = 0; NMC[i] = sign * MathSqrt(MathAbs(avg)); if(Show_ZH) { if(NMC[i] == 0) ZH[i] = ZH_displacement; else ZH[i] = EMPTY_VALUE; } } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - NMC_period - 1 - SD_len) { if(Show_SD_1line_only) { if(NMC[i] == 0) SD[i] = 0; else if(NMC[i] > 0) SD[i] = iBandsOnArray(NMC, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMC[i] < 0) SD[i] = iBandsOnArray(NMC, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } else { if(NMC[i] == 0) { if(Show_SD_2lines_up) SD[i] = 0; if(Show_SD_2lines_dn) SD2[i] = 0; } else { if(Show_SD_2lines_up) SD[i] = iBandsOnArray(NMC, 0, SD_len, SD_up, 0, MODE_UPPER, i); if(Show_SD_2lines_dn) SD2[i] = iBandsOnArray(NMC, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } } } if(Show_NMA) for(i = limit; i >= 0; i--) if(i < Bars - NMC_period - 1 - NMA_period) { ratio = 0; sum = (NMC[i] - NMC[i+1]) + (NMC[i+1] - NMC[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMC[i+ii] - NMC[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMC[i+ii] - NMC[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMC_NMA[i] = NMC_NMA[i+1] + (NMC[i] - NMC_NMA[i+1]) * ratio; } if(Show_FastNMA) for(i = limit; i >= 0; i--) if(i < Bars - NMC_period - 1 - NMA_period) { maxnmc = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmcnum = (NMC[i] - NMC[i+ii]) / MathSqrt(ii); if(MathAbs(nmcnum) > maxnmc) { maxnmc = MathAbs(nmcnum); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMC[i] - NMC[i+1]) + (NMC[i+1] - NMC[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMC[i+ii] - NMC[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMC[i+ii] - NMC[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMC_FastNMA[i] = NMC_FastNMA[i+1] + (NMC[i] - NMC_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/bpVFvmkV for-ex, damo1713005996, mashki and 3 others 6 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 Ocn_NMSx for MT4 Ocn_NMSx. #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Magenta #property indicator_color2 Lime #property indicator_color3 Silver #property indicator_color4 Silver #property indicator_color5 Yellow #property indicator_color6 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMS_period = 40; extern bool Show_ZH = true; extern double ZH_displacement = 1; extern int ZH_symbol = 115; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; extern bool Show_SD_1line_only = true; extern bool Show_SD_2lines_up = true; extern bool Show_SD_2lines_dn = true; extern int NMA_period = 40; extern int NMA_LB_min = 8; extern bool Show_NMA = true; extern bool Show_FastNMA = true; double NMS[]; double ZH[]; double SD[]; double SD2[]; double NMS_NMA[]; double NMS_FastNMA[]; int init() { string nmsname = "NMS(" + NMS_period + ")"; IndicatorShortName(nmsname); IndicatorBuffers(6); SetIndexBuffer(0, NMS); SetIndexLabel(0, nmsname); SetIndexBuffer(1, ZH); SetIndexLabel(1, "NMS_ZH"); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, ZH_symbol); SetIndexBuffer(2, SD); SetIndexBuffer(3, SD2); if(Show_SD_1line_only) { SetIndexLabel(2, "NMS_SD(" + SD_len + ")"); SetIndexLabel(3, "unused"); } else { if(Show_SD_2lines_up) SetIndexLabel(2, "NMS_SD_up(" + SD_len + ")"); else SetIndexLabel(2, "unused"); if(Show_SD_2lines_dn) SetIndexLabel(3, "NMS_SD_dn(" + SD_len + ")"); else SetIndexLabel(3, "unused"); } SetIndexBuffer(4, NMS_NMA); SetIndexBuffer(5, NMS_FastNMA); if(Show_NMA) SetIndexLabel(4, "NMS_NMA(" + NMA_period + ")"); else SetIndexLabel(4, "unused"); if(Show_FastNMA) SetIndexLabel(5, "NMS_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); else SetIndexLabel(5, "unused"); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double nms2, sum, abssum, ratio, nmsnum, maxnms; if(Bars <= NMS_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMS_period) limit = Bars - counted_bars; else limit = Bars - NMS_period - 1; for(i = limit; i >= 0; i--) { nms2 = 0; for(ii = 1; ii <= NMS_period; ii++) { double oLRSlope = 0, SumXY = 0, SumY = 0, SumX, SumXSqr, Divisor; if(ii > 1) { SumX = ii * (ii - 1) * 0.5; SumXSqr = ii * (ii - 1) * (2 * ii - 1) * 1/6; Divisor = (SumX * SumX) - ii * SumXSqr; for(int iii = 0; iii < ii; iii++) { SumXY += iii * MathLog(Close[i+iii]); SumY += MathLog(Close[i+iii]); } oLRSlope = (ii * SumXY - SumX * SumY) / Divisor; } nms2 += oLRSlope * MathSqrt(ii); } NMS[i] = nms2 * 100; if(Show_ZH) { if(NMS[i] == 0) ZH[i] = ZH_displacement; else ZH[i] = EMPTY_VALUE; } } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - NMS_period - 1 - SD_len) { if(Show_SD_1line_only) { if(NMS[i] == 0) SD[i] = 0; else if(NMS[i] > 0) SD[i] = iBandsOnArray(NMS, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMS[i] < 0) SD[i] = iBandsOnArray(NMS, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } else { if(NMS[i] == 0) { if(Show_SD_2lines_up) SD[i] = 0; if(Show_SD_2lines_dn) SD2[i] = 0; } else { if(Show_SD_2lines_up) SD[i] = iBandsOnArray(NMS, 0, SD_len, SD_up, 0, MODE_UPPER, i); if(Show_SD_2lines_dn) SD2[i] = iBandsOnArray(NMS, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } } } if(Show_NMA) for(i = limit; i >= 0; i--) if(i < Bars - NMS_period - 1 - NMA_period) { ratio = 0; sum = (NMS[i] - NMS[i+1]) + (NMS[i+1] - NMS[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMS[i+ii] - NMS[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMS[i+ii] - NMS[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMS_NMA[i] = NMS_NMA[i+1] + (NMS[i] - NMS_NMA[i+1]) * ratio; } if(Show_FastNMA) for(i = limit; i >= 0; i--) if(i < Bars - NMS_period - 1 - NMA_period) { maxnms = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmsnum = (NMS[i] - NMS[i+ii]) / MathSqrt(ii); if(MathAbs(nmsnum) > maxnms) { maxnms = MathAbs(nmsnum); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMS[i] - NMS[i+1]) + (NMS[i+1] - NMS[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMS[i+ii] - NMS[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMS[i+ii] - NMS[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMS_FastNMA[i] = NMS_FastNMA[i+1] + (NMS[i] - NMS_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/3HJn1jfX damo1713005996, for-ex, mashki and 4 others 7 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 Ocn_NMRx for MT4 Ocn_NMRx. This poor one didn't even have NMAs, now it does :) #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Magenta #property indicator_color2 Lime #property indicator_color3 Silver #property indicator_color4 Silver #property indicator_color5 Yellow #property indicator_color6 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMR_period = 40; extern bool Show_ZH = true; extern double ZH_displacement = 1; extern int ZH_symbol = 115; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; extern bool Show_SD_1line_only = true; extern bool Show_SD_2lines_up = true; extern bool Show_SD_2lines_dn = true; extern int NMA_period = 40; extern int NMA_LB_min = 8; extern bool Show_NMA = true; extern bool Show_FastNMA = true; double NMR[]; double ZH[]; double SD[]; double SD2[]; double NMR_NMA[]; double NMR_FastNMA[]; int init() { string nmrname = "NMR(" + NMR_period + ")"; IndicatorShortName(nmrname); IndicatorBuffers(6); SetIndexBuffer(0, NMR); SetIndexLabel(0, nmrname); SetIndexBuffer(1, ZH); SetIndexLabel(1, "NMR_ZH"); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, ZH_symbol); SetIndexBuffer(2, SD); SetIndexBuffer(3, SD2); if(Show_SD_1line_only) { SetIndexLabel(2, "NMR_SD(" + SD_len + ")"); SetIndexLabel(3, "unused"); } else { if(Show_SD_2lines_up) SetIndexLabel(2, "NMR_SD_up(" + SD_len + ")"); else SetIndexLabel(2, "unused"); if(Show_SD_2lines_dn) SetIndexLabel(3, "NMR_SD_dn(" + SD_len + ")"); else SetIndexLabel(3, "unused"); } SetIndexBuffer(4, NMR_NMA); SetIndexBuffer(5, NMR_FastNMA); if(Show_NMA) SetIndexLabel(4, "NMR_NMA(" + NMA_period + ")"); else SetIndexLabel(4, "unused"); if(Show_FastNMA) SetIndexLabel(5, "NMR_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); else SetIndexLabel(5, "unused"); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double nmr2, sum, abssum, ratio, nmrnum, maxnmr; if(Bars <= NMR_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMR_period) limit = Bars - counted_bars; else limit = Bars - NMR_period - 1; for(i = limit; i >= 0; i--) { nmr2 = 0; for(ii = 1; ii <= NMR_period; ii++) nmr2 += (MathLog(Close[i+ii-1]) - MathLog(Close[i+ii])) * (MathSqrt(ii) - MathSqrt(ii-1)); NMR[i] = nmr2 * 1000; if(Show_ZH) { if(NMR[i] == 0) ZH[i] = ZH_displacement; else ZH[i] = EMPTY_VALUE; } } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - NMR_period - 1 - SD_len) { if(Show_SD_1line_only) { if(NMR[i] == 0) SD[i] = 0; else if(NMR[i] > 0) SD[i] = iBandsOnArray(NMR, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMR[i] < 0) SD[i] = iBandsOnArray(NMR, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } else { if(NMR[i] == 0) { if(Show_SD_2lines_up) SD[i] = 0; if(Show_SD_2lines_dn) SD2[i] = 0; } else { if(Show_SD_2lines_up) SD[i] = iBandsOnArray(NMR, 0, SD_len, SD_up, 0, MODE_UPPER, i); if(Show_SD_2lines_dn) SD2[i] = iBandsOnArray(NMR, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } } } if(Show_NMA) for(i = limit; i >= 0; i--) if(i < Bars - NMR_period - 1 - NMA_period) { ratio = 0; sum = (NMR[i] - NMR[i+1]) + (NMR[i+1] - NMR[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMR[i+ii] - NMR[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMR[i+ii] - NMR[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMR_NMA[i] = NMR_NMA[i+1] + (NMR[i] - NMR_NMA[i+1]) * ratio; } if(Show_FastNMA) for(i = limit; i >= 0; i--) if(i < Bars - NMR_period - 1 - NMA_period) { maxnmr = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmrnum = (NMR[i] - NMR[i+ii]) / MathSqrt(ii); if(MathAbs(nmrnum) > maxnmr) { maxnmr = MathAbs(nmrnum); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMR[i] - NMR[i+1]) + (NMR[i+1] - NMR[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMR[i+ii] - NMR[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMR[i+ii] - NMR[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMR_FastNMA[i] = NMR_FastNMA[i+1] + (NMR[i] - NMR_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/eUTa0wTj C0UNDE, mashki, tgt123 and 3 others 6 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 Ocn_NMMx for MT4 Ocn_NMMx. #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Magenta #property indicator_color2 Lime #property indicator_color3 Silver #property indicator_color4 Silver #property indicator_color5 Yellow #property indicator_color6 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMM_period = 40; extern bool Show_ZH = true; extern double ZH_displacement = 1; extern int ZH_symbol = 115; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; extern bool Show_SD_1line_only = true; extern bool Show_SD_2lines_up = true; extern bool Show_SD_2lines_dn = true; extern int NMA_period = 40; extern int NMA_LB_min = 8; extern bool Show_NMA = true; extern bool Show_FastNMA = true; double NMM[]; double ZH[]; double SD[]; double SD2[]; double NMM_NMA[]; double NMM_FastNMA[]; int init() { string nmmname = "NMM(" + NMM_period + ")"; IndicatorShortName(nmmname); IndicatorBuffers(6); SetIndexBuffer(0, NMM); SetIndexLabel(0, nmmname); SetIndexBuffer(1, ZH); SetIndexLabel(1, "NMM_ZH"); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, ZH_symbol); SetIndexBuffer(2, SD); SetIndexBuffer(3, SD2); if(Show_SD_1line_only) { SetIndexLabel(2, "NMM_SD(" + SD_len + ")"); SetIndexLabel(3, "unused"); } else { if(Show_SD_2lines_up) SetIndexLabel(2, "NMM_SD_up(" + SD_len + ")"); else SetIndexLabel(2, "unused"); if(Show_SD_2lines_dn) SetIndexLabel(3, "NMM_SD_dn(" + SD_len + ")"); else SetIndexLabel(3, "unused"); } SetIndexBuffer(4, NMM_NMA); SetIndexBuffer(5, NMM_FastNMA); if(Show_NMA) SetIndexLabel(4, "NMM_NMA(" + NMA_period + ")"); else SetIndexLabel(4, "unused"); if(Show_FastNMA) SetIndexLabel(5, "NMM_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); else SetIndexLabel(5, "unused"); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double nmm2, sum, abssum, ratio, nmmnum, maxnmm; if(Bars <= NMM_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMM_period) limit = Bars - counted_bars; else limit = Bars - NMM_period - 1; for(i = limit; i >= 0; i--) { nmm2 = 0; for(ii = 1; ii <= NMM_period; ii++) nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); NMM[i] = (nmm2 / NMM_period) * 1000; if(Show_ZH) { if(NMM[i] == 0) ZH[i] = ZH_displacement; else ZH[i] = EMPTY_VALUE; } } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - NMM_period - 1 - SD_len) { if(Show_SD_1line_only) { if(NMM[i] == 0) SD[i] = 0; else if(NMM[i] > 0) SD[i] = iBandsOnArray(NMM, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMM[i] < 0) SD[i] = iBandsOnArray(NMM, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } else { if(NMM[i] == 0) { if(Show_SD_2lines_up) SD[i] = 0; if(Show_SD_2lines_dn) SD2[i] = 0; } else { if(Show_SD_2lines_up) SD[i] = iBandsOnArray(NMM, 0, SD_len, SD_up, 0, MODE_UPPER, i); if(Show_SD_2lines_dn) SD2[i] = iBandsOnArray(NMM, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } } } if(Show_NMA) for(i = limit; i >= 0; i--) if(i < Bars - NMM_period - 1 - NMA_period) { ratio = 0; sum = (NMM[i] - NMM[i+1]) + (NMM[i+1] - NMM[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMM[i+ii] - NMM[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMM[i+ii] - NMM[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_NMA[i] = NMM_NMA[i+1] + (NMM[i] - NMM_NMA[i+1]) * ratio; } if(Show_FastNMA) for(i = limit; i >= 0; i--) if(i < Bars - NMM_period - 1 - NMA_period) { maxnmm = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmmnum = (NMM[i] - NMM[i+ii]) / MathSqrt(ii); if(MathAbs(nmmnum) > maxnmm) { maxnmm = MathAbs(nmmnum); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMM[i] - NMM[i+1]) + (NMM[i+1] - NMM[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMM[i+ii] - NMM[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMM[i+ii] - NMM[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_FastNMA[i] = NMM_FastNMA[i+1] + (NMM[i] - NMM_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/1vnYXeFm for-ex, C0UNDE, fawaz79 and 2 others 5 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 Ocn_NMM_Ocean_Indexx Ocn_NMM_Ocean_Indexx. This one also didn't have NMAs. Kinda silly name but since I am giving all these final versions a suffix "x" this is what I got. Of course you can rename it whatever you wish. #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Magenta #property indicator_color2 Lime #property indicator_color3 Silver #property indicator_color4 Silver #property indicator_color5 Yellow #property indicator_color6 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMM_LB = 21; extern bool Show_ZH = true; extern double ZH_displacement = 1; extern int ZH_symbol = 115; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; extern bool Show_SD_1line_only = true; extern bool Show_SD_2lines_up = true; extern bool Show_SD_2lines_dn = true; extern int NMA_period = 40; extern int NMA_LB_min = 8; extern bool Show_NMA = true; extern bool Show_FastNMA = true; double NMM[]; double ZH[]; double SD[]; double SD2[]; double NMM_NMA[]; double NMM_FastNMA[]; int init() { string nmmname = "NMM_Ocean_Index(" + NMM_LB + ")"; IndicatorShortName(nmmname); IndicatorBuffers(6); SetIndexBuffer(0, NMM); SetIndexLabel(0, nmmname); SetIndexBuffer(1, ZH); SetIndexLabel(1, "NMM_Ocean_Index_ZH"); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, ZH_symbol); SetIndexBuffer(2, SD); SetIndexBuffer(3, SD2); if(Show_SD_1line_only) { SetIndexLabel(2, "NMM_Ocean_Index_SD(" + SD_len + ")"); SetIndexLabel(3, "unused"); } else { if(Show_SD_2lines_up) SetIndexLabel(2, "NMM_Ocean_Index_SD_up(" + SD_len + ")"); else SetIndexLabel(2, "unused"); if(Show_SD_2lines_dn) SetIndexLabel(3, "NMM_Ocean_Index_SD_dn(" + SD_len + ")"); else SetIndexLabel(3, "unused"); } SetIndexBuffer(4, NMM_NMA); SetIndexBuffer(5, NMM_FastNMA); if(Show_NMA) SetIndexLabel(4, "NMM_Ocean_Index_NMA(" + NMA_period + ")"); else SetIndexLabel(4, "unused"); if(Show_FastNMA) SetIndexLabel(5, "NMM_Ocean_Index_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); else SetIndexLabel(5, "unused"); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double sum, abssum, ratio, nmmnum, maxnmm; if(Bars <= NMM_LB) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMM_LB) limit = Bars - counted_bars; else limit = Bars - NMM_LB - 1; for(i = limit; i >= 0; i--) { NMM[i] = (MathLog(Close[i]) - MathLog(Close[i+NMM_LB])) / MathSqrt(NMM_LB) * 1000; if(Show_ZH) { if(NMM[i] == 0) ZH[i] = ZH_displacement; else ZH[i] = EMPTY_VALUE; } } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - NMM_LB - 1 - SD_len) { if(Show_SD_1line_only) { if(NMM[i] == 0) SD[i] = 0; else if(NMM[i] > 0) SD[i] = iBandsOnArray(NMM, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMM[i] < 0) SD[i] = iBandsOnArray(NMM, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } else { if(NMM[i] == 0) { if(Show_SD_2lines_up) SD[i] = 0; if(Show_SD_2lines_dn) SD2[i] = 0; } else { if(Show_SD_2lines_up) SD[i] = iBandsOnArray(NMM, 0, SD_len, SD_up, 0, MODE_UPPER, i); if(Show_SD_2lines_dn) SD2[i] = iBandsOnArray(NMM, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } } } if(Show_NMA) for(i = limit; i >= 0; i--) if(i < Bars - NMM_LB - 1 - NMA_period) { ratio = 0; sum = (NMM[i] - NMM[i+1]) + (NMM[i+1] - NMM[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMM[i+ii] - NMM[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMM[i+ii] - NMM[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_NMA[i] = NMM_NMA[i+1] + (NMM[i] - NMM_NMA[i+1]) * ratio; } if(Show_FastNMA) for(i = limit; i >= 0; i--) if(i < Bars - NMM_LB - 1 - NMA_period) { maxnmm = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmmnum = (NMM[i] - NMM[i+ii]) / MathSqrt(ii); if(MathAbs(nmmnum) > maxnmm) { maxnmm = MathAbs(nmmnum); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMM[i] - NMM[i+1]) + (NMM[i+1] - NMM[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMM[i+ii] - NMM[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMM[i+ii] - NMM[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_FastNMA[i] = NMM_FastNMA[i+1] + (NMM[i] - NMM_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/z1ibswJF mashki, C0UNDE, fawaz79 and 2 others 5 Quote Link to comment Share on other sites More sharing options...
udc Posted April 8, 2012 Author Report Share Posted April 8, 2012 Ocn_NMAx for MT4 Ocn_NMAx. Both NMA and FastNMA, each with its own SD bands, all together in a single indicator. You can selectively turn on/off each of all 6 lines, i.e. you can leave only NMA's upper SD band and FastNMA's lower SD band visible and everything else turn off :) #property indicator_chart_window #property indicator_buffers 6 #property indicator_color1 Yellow #property indicator_color2 Gray #property indicator_color3 Gray #property indicator_color4 Aqua #property indicator_color5 Blue #property indicator_color6 Blue extern bool Show_NMA = true; extern int NMA_period = 40; extern int NMA_SD_len = 30; extern bool Show_NMA_SD_up = true; extern double NMA_SD_up = 2; extern bool Show_NMA_SD_dn = true; extern double NMA_SD_dn = 2; extern bool Show_FastNMA = true; extern int FastNMA_period = 40; extern int FastNMA_LB_min = 8; extern int FastNMA_SD_len = 20; extern bool Show_FastNMA_SD_up = true; extern double FastNMA_SD_up = 1.5; extern bool Show_FastNMA_SD_dn = true; extern double FastNMA_SD_dn = 1.5; double NMA[]; double NMA_SDup[]; double NMA_SDdn[]; double FastNMA[]; double FastNMA_SDup[]; double FastNMA_SDdn[]; double NMAx[]; double FastNMAx[]; int init() { IndicatorShortName("NMA(" + NMA_period + ", " + FastNMA_period + ", " + FastNMA_LB_min + ")"); IndicatorBuffers(8); string nmaname = "NMA(" + NMA_period + ")"; string nmasdname = "NMA_SD(" + NMA_SD_len + ")"; string fastnmaname = "FastNMA(" + FastNMA_period + ", " + FastNMA_LB_min + ")"; string fastnmasdname = "FastNMA_SD(" + FastNMA_SD_len + ")"; SetIndexBuffer(0, NMA); SetIndexBuffer(1, NMA_SDup); SetIndexBuffer(2, NMA_SDdn); SetIndexBuffer(3, FastNMA); SetIndexBuffer(4, FastNMA_SDup); SetIndexBuffer(5, FastNMA_SDdn); SetIndexBuffer(6, NMAx); SetIndexBuffer(7, FastNMAx); if(Show_NMA) SetIndexLabel(0, nmaname); else SetIndexLabel(0, "unused"); if(Show_NMA_SD_up) SetIndexLabel(1, nmasdname+"_up"); else SetIndexLabel(1, "unused"); if(Show_NMA_SD_dn) SetIndexLabel(2, nmasdname+"_dn"); else SetIndexLabel(2, "unused"); if(Show_FastNMA) SetIndexLabel(3, fastnmaname); else SetIndexLabel(3, "unused"); if(Show_FastNMA_SD_up) SetIndexLabel(4, fastnmasdname+"_up"); else SetIndexLabel(4, "unused"); if(Show_FastNMA_SD_dn) SetIndexLabel(5, fastnmasdname+"_dn"); else SetIndexLabel(5, "unused"); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); int max = MathMax(MathMax(Show_NMA * NMA_period, MathMax(Show_NMA_SD_up, Show_NMA_SD_dn) * MathMax(NMA_period, NMA_SD_len)), MathMax(Show_FastNMA * FastNMA_period, MathMax(Show_FastNMA_SD_up, Show_FastNMA_SD_dn) * MathMax(FastNMA_period, FastNMA_SD_len))); double sum, abssum, ratio, nmmnum, maxnmm; if(Bars <= max) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > max) limit = Bars - counted_bars; else limit = Bars - max - 1; for(i = limit; i >= 0; i--) { ratio = 0; sum = (MathLog(Close[i]) - MathLog(Close[i+1])) + (MathLog(Close[i+1]) - MathLog(Close[i+2])) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (MathLog(Close[i+ii]) - MathLog(Close[i+ii+1])) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(MathLog(Close[i+ii]) - MathLog(Close[i+ii+1])); if(sum != 0) ratio = abssum / sum; NMAx[i] = NMAx[i+1] + (Close[i] - NMAx[i+1]) * ratio; if(Show_NMA) NMA[i] = NMAx[i]; if(Show_NMA_SD_up) NMA_SDup[i] = NMAx[i] + NMA_SD_up * iStdDev(NULL, 0, NMA_SD_len, 0, 0, PRICE_CLOSE, i); if(Show_NMA_SD_dn) NMA_SDdn[i] = NMAx[i] - NMA_SD_dn * iStdDev(NULL, 0, NMA_SD_len, 0, 0, PRICE_CLOSE, i); } for(i = limit; i >= 0; i--) { maxnmm = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= FastNMA_period; ii++) { nmmnum = (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); if(MathAbs(nmmnum) > maxnmm) { maxnmm = MathAbs(nmmnum); NMA_LB_max = ii; } } if(NMA_LB_max < FastNMA_LB_min) NMA_LB_max = FastNMA_LB_min; sum = (MathLog(Close[i]) - MathLog(Close[i+1])) + (MathLog(Close[i+1]) - MathLog(Close[i+2])) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (MathLog(Close[i+ii]) - MathLog(Close[i+ii+1])) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(MathLog(Close[i+ii]) - MathLog(Close[i+ii+1])); if(sum != 0) ratio = abssum / sum; FastNMAx[i] = FastNMAx[i+1] + (Close[i] - FastNMAx[i+1]) * ratio; if(Show_FastNMA) FastNMA[i] = FastNMAx[i]; if(Show_FastNMA_SD_up) FastNMA_SDup[i] = FastNMAx[i] + FastNMA_SD_up * iStdDev(NULL, 0, FastNMA_SD_len, 0, 0, PRICE_CLOSE, i); if(Show_FastNMA_SD_dn) FastNMA_SDdn[i] = FastNMAx[i] - FastNMA_SD_dn * iStdDev(NULL, 0, FastNMA_SD_len, 0, 0, PRICE_CLOSE, i); } return(0); } The source code is also available for download here: http://pastebin.com/5N5DX4SZ tgt123, mashki, for-ex and 2 others 5 Quote Link to comment Share on other sites More sharing options...
udc Posted April 9, 2012 Author Report Share Posted April 9, 2012 Ocn_NMM_ROCx for MT4 Ocn_NMM_ROCx. #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Magenta #property indicator_color2 Lime #property indicator_color3 Silver #property indicator_color4 Silver #property indicator_color5 Yellow #property indicator_color6 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMM_ROC_period = 40; extern int NMM_ROC_LB = 3; extern int NMM_ROC_AvgLen = 3; extern bool Show_ZH = true; extern double ZH_displacement = 1; extern int ZH_symbol = 115; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; extern bool Show_SD_1line_only = true; extern bool Show_SD_2lines_up = true; extern bool Show_SD_2lines_dn = true; extern int NMA_period = 40; extern int NMA_LB_min = 8; extern bool Show_NMA = true; extern bool Show_FastNMA = true; double NMM_ROC[]; double ZH[]; double SD[]; double SD2[]; double NMM_ROC_NMA[]; double NMM_ROC_FastNMA[]; double NMM[]; double NMM_ROCx[]; int init() { string nmmrocname = "NMM_ROC(" + NMM_ROC_period + ", " + NMM_ROC_LB + ", " + NMM_ROC_AvgLen + ")"; IndicatorShortName(nmmrocname); IndicatorBuffers(8); SetIndexBuffer(0, NMM_ROC); SetIndexLabel(0, nmmrocname); SetIndexBuffer(1, ZH); SetIndexLabel(1, "NMM_ROC_ZH"); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, ZH_symbol); SetIndexBuffer(2, SD); SetIndexBuffer(3, SD2); if(Show_SD_1line_only) { SetIndexLabel(2, "NMM_ROC_SD(" + SD_len + ")"); SetIndexLabel(3, "unused"); } else { if(Show_SD_2lines_up) SetIndexLabel(2, "NMM_ROC_SD_up(" + SD_len + ")"); else SetIndexLabel(2, "unused"); if(Show_SD_2lines_dn) SetIndexLabel(3, "NMM_ROC_SD_dn(" + SD_len + ")"); else SetIndexLabel(3, "unused"); } SetIndexBuffer(4, NMM_ROC_NMA); SetIndexBuffer(5, NMM_ROC_FastNMA); if(Show_NMA) SetIndexLabel(4, "NMM_ROC_NMA(" + NMA_period + ")"); else SetIndexLabel(4, "unused"); if(Show_FastNMA) SetIndexLabel(5, "NMM_ROC_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); else SetIndexLabel(5, "unused"); SetIndexBuffer(6, NMM); SetIndexBuffer(7, NMM_ROCx); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double nmm2, sum, abssum, ratio, nmmrocnum, maxnmmroc; if(Bars <= NMM_ROC_period + NMM_ROC_LB + NMM_ROC_AvgLen) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMM_ROC_period) limit = Bars - counted_bars; else limit = Bars - NMM_ROC_period - 1; for(i = limit; i >= 0; i--) { nmm2 = 0; for(ii = 1; ii <= NMM_ROC_period; ii++) nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); NMM[i] = (nmm2 / NMM_ROC_period) * 1000; } for(i = limit; i >= 0; i--) if(i < Bars - NMM_ROC_period - 1 - NMM_ROC_LB) NMM_ROCx[i] = NMM[i] - NMM[i+NMM_ROC_LB]; for(i = limit; i >= 0; i--) if(i < Bars - NMM_ROC_period - 1 - NMM_ROC_LB - NMM_ROC_AvgLen) { double WtdSum = 0; for(ii = 0; ii < NMM_ROC_AvgLen; ii++) WtdSum += (NMM_ROC_AvgLen - ii) * NMM_ROCx[i+ii]; NMM_ROC[i] = WtdSum / ((NMM_ROC_AvgLen + 1) * NMM_ROC_AvgLen * 0.5); if(Show_ZH) { if(NMM_ROC[i] == 0) ZH[i] = ZH_displacement; else ZH[i] = EMPTY_VALUE; } } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - NMM_ROC_period - 1 - NMM_ROC_LB - NMM_ROC_AvgLen - SD_len) { if(Show_SD_1line_only) { if(NMM_ROC[i] == 0) SD[i] = 0; else if(NMM_ROC[i] > 0) SD[i] = iBandsOnArray(NMM_ROC, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMM_ROC[i] < 0) SD[i] = iBandsOnArray(NMM_ROC, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } else { if(NMM_ROC[i] == 0) { if(Show_SD_2lines_up) SD[i] = 0; if(Show_SD_2lines_dn) SD2[i] = 0; } else { if(Show_SD_2lines_up) SD[i] = iBandsOnArray(NMM_ROC, 0, SD_len, SD_up, 0, MODE_UPPER, i); if(Show_SD_2lines_dn) SD2[i] = iBandsOnArray(NMM_ROC, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } } } if(Show_NMA) for(i = limit; i >= 0; i--) if(i < Bars - NMM_ROC_period - 1 - NMM_ROC_LB - NMM_ROC_AvgLen - NMA_period) { ratio = 0; sum = (NMM_ROC[i] - NMM_ROC[i+1]) + (NMM_ROC[i+1] - NMM_ROC[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMM_ROC[i+ii] - NMM_ROC[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMM_ROC[i+ii] - NMM_ROC[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_ROC_NMA[i] = NMM_ROC_NMA[i+1] + (NMM_ROC[i] - NMM_ROC_NMA[i+1]) * ratio; } if(Show_FastNMA) for(i = limit; i >= 0; i--) if(i < Bars - NMM_ROC_period - 1 - NMM_ROC_LB - NMM_ROC_AvgLen - NMA_period) { maxnmmroc = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmmrocnum = (NMM_ROC[i] - NMM_ROC[i+ii]) / MathSqrt(ii); if(MathAbs(nmmrocnum) > maxnmmroc) { maxnmmroc = MathAbs(nmmrocnum); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMM_ROC[i] - NMM_ROC[i+1]) + (NMM_ROC[i+1] - NMM_ROC[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMM_ROC[i+ii] - NMM_ROC[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMM_ROC[i+ii] - NMM_ROC[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_ROC_FastNMA[i] = NMM_ROC_FastNMA[i+1] + (NMM_ROC[i] - NMM_ROC_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/FNG3fggz C0UNDE, tgt123, fawaz79 and 2 others 5 Quote Link to comment Share on other sites More sharing options...
udc Posted April 9, 2012 Author Report Share Posted April 9, 2012 Ocn_NMA_SD_Band_Oscx for MT4 Ocn_NMA_SD_Band_Oscx. Compared to the original version, there are 2 improvements: you can display both NMA and FastNMA band oscilators at the same time the whole indicator is shifted by 50 down, so now the middle (when the price is at NMA/FastNMA) is at 0 and the bands are at 50 and -50 (compared to original middle at 50 and bands at 0 and 100), thus you can now use it more like CCI and also its better suitable for use in strategies #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Yellow #property indicator_color2 Aqua #property indicator_level1 50 #property indicator_level2 0 #property indicator_level3 -50 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern bool Show_NMA = true; extern int NMA_period = 40; extern int NMA_SD_len = 30; extern double NMA_SD_up = 2; extern double NMA_SD_dn = 2; extern bool Show_FastNMA = true; extern int FastNMA_period = 40; extern int FastNMA_LB_min = 8; extern int FastNMA_SD_len = 20; extern double FastNMA_SD_up = 1.5; extern double FastNMA_SD_dn = 1.5; double NMA_SD_Band_Osc[]; double NMA[]; double NMA_SDup[]; double NMA_SDdn[]; double FastNMA_SD_Band_Osc[]; double FastNMA[]; double FastNMA_SDup[]; double FastNMA_SDdn[]; int init() { IndicatorShortName("NMA_SD_Band_Osc(" + NMA_period + ", " + FastNMA_period + ", " + FastNMA_LB_min + ")"); IndicatorBuffers(8); SetIndexBuffer(0, NMA_SD_Band_Osc); SetIndexLabel(0, "NMA_SD_Band_Osc(" + NMA_period + ")"); SetIndexBuffer(1, FastNMA_SD_Band_Osc); SetIndexLabel(1, "FastNMA_SD_Band_Osc(" + FastNMA_period + ", " + FastNMA_LB_min + ")"); SetIndexBuffer(2, NMA); SetIndexBuffer(3, NMA_SDup); SetIndexBuffer(4, NMA_SDdn); SetIndexBuffer(5, FastNMA); SetIndexBuffer(6, FastNMA_SDup); SetIndexBuffer(7, FastNMA_SDdn); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); int max = MathMax(Show_NMA * MathMax(NMA_period, NMA_SD_len), Show_FastNMA * MathMax(FastNMA_period, FastNMA_SD_len)); double sum, abssum, ratio, nmmnum, maxnmm; if(Bars <= max) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > max) limit = Bars - counted_bars; else limit = Bars - max - 1; if(Show_NMA) for(i = limit; i >= 0; i--) { ratio = 0; sum = (MathLog(Close[i]) - MathLog(Close[i+1])) + (MathLog(Close[i+1]) - MathLog(Close[i+2])) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (MathLog(Close[i+ii]) - MathLog(Close[i+ii+1])) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(MathLog(Close[i+ii]) - MathLog(Close[i+ii+1])); if(sum != 0) ratio = abssum / sum; NMA[i] = NMA[i+1] + (Close[i] - NMA[i+1]) * ratio; NMA_SDup[i] = NMA[i] + NMA_SD_up * iStdDev(NULL, 0, NMA_SD_len, 0, 0, PRICE_CLOSE, i); NMA_SDdn[i] = NMA[i] - NMA_SD_dn * iStdDev(NULL, 0, NMA_SD_len, 0, 0, PRICE_CLOSE, i); NMA_SD_Band_Osc[i] = ((Close[i] - NMA_SDdn[i]) / (NMA_SDup[i] - NMA_SDdn[i]) * 100) - 50; } if(Show_FastNMA) for(i = limit; i >= 0; i--) { maxnmm = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= FastNMA_period; ii++) { nmmnum = (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); if(MathAbs(nmmnum) > maxnmm) { maxnmm = MathAbs(nmmnum); NMA_LB_max = ii; } } if(NMA_LB_max < FastNMA_LB_min) NMA_LB_max = FastNMA_LB_min; sum = (MathLog(Close[i]) - MathLog(Close[i+1])) + (MathLog(Close[i+1]) - MathLog(Close[i+2])) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (MathLog(Close[i+ii]) - MathLog(Close[i+ii+1])) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(MathLog(Close[i+ii]) - MathLog(Close[i+ii+1])); if(sum != 0) ratio = abssum / sum; FastNMA[i] = FastNMA[i+1] + (Close[i] - FastNMA[i+1]) * ratio; FastNMA_SDup[i] = FastNMA[i] + FastNMA_SD_up * iStdDev(NULL, 0, FastNMA_SD_len, 0, 0, PRICE_CLOSE, i); FastNMA_SDdn[i] = FastNMA[i] - FastNMA_SD_dn * iStdDev(NULL, 0, FastNMA_SD_len, 0, 0, PRICE_CLOSE, i); FastNMA_SD_Band_Osc[i] = ((Close[i] - FastNMA_SDdn[i]) / (FastNMA_SDup[i] - FastNMA_SDdn[i]) * 100) - 50; } return(0); } The source code is also available for download here: http://pastebin.com/HxQ92uEx for-ex, C0UNDE, mashki and 2 others 5 Quote Link to comment Share on other sites More sharing options...
udc Posted April 9, 2012 Author Report Share Posted April 9, 2012 Ocn_NMM_MACDx for MT4 Ocn_NMM_MACDx. #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Magenta #property indicator_color2 Lime #property indicator_color3 Silver #property indicator_color4 Silver #property indicator_color5 Yellow #property indicator_color6 Aqua #property indicator_level1 0 #property indicator_levelcolor Gray #property indicator_levelstyle 2 extern int NMM_MACD_period = 40; extern bool Show_ZH = true; extern double ZH_displacement = 1; extern int ZH_symbol = 115; extern bool Show_SD = true; extern int SD_len = 30; extern double SD_up = 2; extern double SD_dn = 2; extern bool Show_SD_1line_only = true; extern bool Show_SD_2lines_up = true; extern bool Show_SD_2lines_dn = true; extern int NMA_period = 40; extern int NMA_LB_min = 8; extern bool Show_NMA = true; extern bool Show_FastNMA = true; double NMM_MACD[]; double ZH[]; double SD[]; double SD2[]; double NMM_MACD_NMA[]; double NMM_MACD_FastNMA[]; double NMM[]; double NMM_MA[]; int init() { string nmmmacdname = "NMM_MACD(" + NMM_MACD_period + ")"; IndicatorShortName(nmmmacdname); IndicatorBuffers(8); SetIndexBuffer(0, NMM_MACD); SetIndexLabel(0, nmmmacdname); SetIndexBuffer(1, ZH); SetIndexLabel(1, "NMM_MACD_ZH"); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, ZH_symbol); SetIndexBuffer(2, SD); SetIndexBuffer(3, SD2); if(Show_SD_1line_only) { SetIndexLabel(2, "NMM_MACD_SD(" + SD_len + ")"); SetIndexLabel(3, "unused"); } else { if(Show_SD_2lines_up) SetIndexLabel(2, "NMM_MACD_SD_up(" + SD_len + ")"); else SetIndexLabel(2, "unused"); if(Show_SD_2lines_dn) SetIndexLabel(3, "NMM_MACD_SD_dn(" + SD_len + ")"); else SetIndexLabel(3, "unused"); } SetIndexBuffer(4, NMM_MACD_NMA); SetIndexBuffer(5, NMM_MACD_FastNMA); if(Show_NMA) SetIndexLabel(4, "NMM_MACD_NMA(" + NMA_period + ")"); else SetIndexLabel(4, "unused"); if(Show_FastNMA) SetIndexLabel(5, "NMM_MACD_FastNMA(" + NMA_period + ", " + NMA_LB_min + ")"); else SetIndexLabel(5, "unused"); SetIndexBuffer(6, NMM); SetIndexBuffer(7, NMM_MA); return(0); } int start() { int limit, i, ii, counted_bars = IndicatorCounted(); double nmm2, sum, abssum, ratio, nmmmacdnum, maxnmmmacd; if(Bars <= 2*NMM_MACD_period) return(0); if(counted_bars < 0) counted_bars = 0; if(counted_bars > NMM_MACD_period) limit = Bars - counted_bars; else limit = Bars - NMM_MACD_period - 1; for(i = limit; i >= 0; i--) { nmm2 = 0; for(ii = 1; ii <= NMM_MACD_period; ii++) nmm2 += (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii); NMM[i] = (nmm2 / NMM_MACD_period) * 1000; } for(i = limit; i >= 0; i--) if(i < Bars - 2*NMM_MACD_period - 1) { ratio = 0; sum = (NMM[i] - NMM[i+1]) + (NMM[i+1] - NMM[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMM_MACD_period; ii++) sum += (NMM[i+ii] - NMM[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMM_MACD_period; ii++) sum += MathAbs(NMM[i+ii] - NMM[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_MA[i] = NMM_MA[i+1] + (NMM[i] - NMM_MA[i+1]) * ratio; NMM_MACD[i] = NMM[i] - NMM_MA[i]; if(Show_ZH) { if(NMM_MACD[i] == 0) ZH[i] = ZH_displacement; else ZH[i] = EMPTY_VALUE; } } if(Show_SD) for(i = limit; i >= 0; i--) if(i < Bars - 2*NMM_MACD_period - 1 - SD_len) { if(Show_SD_1line_only) { if(NMM_MACD[i] == 0) SD[i] = 0; else if(NMM_MACD[i] > 0) SD[i] = iBandsOnArray(NMM_MACD, 0, SD_len, SD_up, 0, MODE_UPPER, i); else if(NMM_MACD[i] < 0) SD[i] = iBandsOnArray(NMM_MACD, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } else { if(NMM_MACD[i] == 0) { if(Show_SD_2lines_up) SD[i] = 0; if(Show_SD_2lines_dn) SD2[i] = 0; } else { if(Show_SD_2lines_up) SD[i] = iBandsOnArray(NMM_MACD, 0, SD_len, SD_up, 0, MODE_UPPER, i); if(Show_SD_2lines_dn) SD2[i] = iBandsOnArray(NMM_MACD, 0, SD_len, SD_dn, 0, MODE_LOWER, i); } } } if(Show_NMA) for(i = limit; i >= 0; i--) if(i < Bars - 2*NMM_MACD_period - 1 - NMA_period) { ratio = 0; sum = (NMM_MACD[i] - NMM_MACD[i+1]) + (NMM_MACD[i+1] - NMM_MACD[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_period; ii++) sum += (NMM_MACD[i+ii] - NMM_MACD[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_period; ii++) sum += MathAbs(NMM_MACD[i+ii] - NMM_MACD[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_MACD_NMA[i] = NMM_MACD_NMA[i+1] + (NMM_MACD[i] - NMM_MACD_NMA[i+1]) * ratio; } if(Show_FastNMA) for(i = limit; i >= 0; i--) if(i < Bars - 2*NMM_MACD_period - 1 - NMA_period) { maxnmmmacd = 0; ratio = 0; int NMA_LB_max; for(ii = 1; ii <= NMA_period; ii++) { nmmmacdnum = (NMM_MACD[i] - NMM_MACD[i+ii]) / MathSqrt(ii); if(MathAbs(nmmmacdnum) > maxnmmmacd) { maxnmmmacd = MathAbs(nmmmacdnum); NMA_LB_max = ii; } } if(NMA_LB_max < NMA_LB_min) NMA_LB_max = NMA_LB_min; sum = (NMM_MACD[i] - NMM_MACD[i+1]) + (NMM_MACD[i+1] - NMM_MACD[i+2]) * (MathSqrt(2)-1); for(ii = 2; ii < NMA_LB_max; ii++) sum += (NMM_MACD[i+ii] - NMM_MACD[i+ii+1]) * (MathSqrt(ii+1) - MathSqrt(ii)); abssum = MathAbs(sum); sum = 0; for(ii = 0; ii < NMA_LB_max; ii++) sum += MathAbs(NMM_MACD[i+ii] - NMM_MACD[i+ii+1]); if(sum != 0) ratio = abssum / sum; NMM_MACD_FastNMA[i] = NMM_MACD_FastNMA[i+1] + (NMM_MACD[i] - NMM_MACD_FastNMA[i+1]) * ratio; } return(0); } The source code is also available for download here: http://pastebin.com/qwN27vxb mashki, for-ex, fawaz79 and 1 other 4 Quote Link to comment Share on other sites More sharing options...
udc Posted April 9, 2012 Author Report Share Posted April 9, 2012 resume Ok, so what I have actually done: renamed NMA_Price_Osc to Ocn_NMA_Price_Osc renamed NMA_SD_Band_Width to Ocn_NMA_SD_Band_Width renamed NMM_X-Ray_1 to Ocn_NMM_X-Ray_1 renamed NMM_X-Ray_2 to Ocn_NMM_X-Ray_2 renamed NMA_SD_Band_Osc to Ocn_NMA_SD_Band_Osc (my improved version has different scale so I am keeping the original version too) improved NMA_SD_Band_Osc into Ocn_NMA_SD_Band_Oscx improved NMM_Ocean_Index into Ocn_NMM_Ocean_Indexx improved NMM_ROC into Ocn_NMM_ROCx improved NMR into Ocn_NMRx improved NMA and Fast_NMA and combined both into a single Ocn_NMAx improved NMC and NMC_with_Ocn_MAs and combined both into a single Ocn_NMCx improved NMC2 and NMC2_with_Ocn_MAs and combined both into a single Ocn_NMC2x improved NMM and NMM_with_Ocn_MAs and combined both into a single Ocn_NMMx improved NMM_MACD and NMM_MACD_with_Ocn_MAs and combined both into a single Ocn_NMM_MACDx improved NMS and NMS_with_Ocn_MAs and combined both into a single Ocn_NMSx If you did the same you would end up with 15 indicators. If not, you can download them from here: http://uloz.to/xTwJmMJ/ocn-7z Now I can finally get to NDX, NST and NXC, and then see about BTX/STX buddies. Sesshoumaru, tgt123, peterke and 13 others 16 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.