Jump to content

udc

Members
  • Posts

    224
  • Joined

  • Last visited

  • Days Won

    24

Posts posted by udc

  1. NDX/NST/NXC with JMA

     

    Here are improved versions of NDX, NST and NXC indis, as well as the cumulative NDXNSTNXC indi, with the option to use JMA instead of TEMA.

     

    Because all the JMA calculations are performed for the whole chart over and over again at every new tick, it may or may not increase the CPU load. For that reason I created a new variable MaxBars to limit the number of history bars onto which the indicator will be applied. For example, MaxBars=500 means that the indicator will be calculated only for 500 most recent bars. MaxBars=0 means to calculate the whole chart.

     

    NDXNSTNXC without JMA and with JMA:

    http://img862.imageshack.us/img862/3974/ndxnstnxcjma.png

     

    Original size screenshot:

    http://img163.imageshack.us/img163/3974/ndxnstnxcjma.png

     

     

    All 19 indis:

    http://uloz.to/xENQnqM/ocn-classic-4-15-2012-7z

  2. RSX vs NDX vs NDX_JMA

     

    Turned out quite nice, see for yourself:

     

    http://img72.imageshack.us/img72/9563/rsxndxjma.png

     

    Original size screenshot:

    http://img685.imageshack.us/img685/9563/rsxndxjma.png

     

    So, first is RSX(14) and NDX with the default TEMA(20). NDX is a bit faster but much more jumpy. Third, yellow, is NDX with JMA(20) instead of TEMA. Way too smooth.

    Fourth, in orange, is NDX with JMA(10). Now we are using smoothing with just a half period than the original NDX's TEMA and yet we are smoother.

    Last one is NDX with JMA(7), that's almost only a third of the original smoothing period but we are still smoother then the original.

     

    Now notice the divergence I marked. RSX recognized it correctly, yet original NDX fails. NDX with JMA(20) is flat, and NDX with JMA(10) and JMA(7) correctly shows the divergence.

    So, if you were at the point of vertical blue line, with RSX you may suspect that it's gonna go down. And you would be right. But with original NDX you might have thought it will go further up.

     

    I would say NDX with JMA(10) is much more better than the original NDX. It's using a smoothing period half of the original size, yet it's smoother, it's more accurate and compared to RSX it's still a little bit faster.

     

    What do you think?

  3. Exactly as you say, when there is a big move TEMA can accumulate so much speed that it manages to change direction not until way beyond the crossroad.

     

    In Ocean indis TEMA is used in 2 cases:

    • a variable SC (smoothing constant) - this is in many Ocean indis and it means pre-smoothing of the price before it's used in the actual math; this variable is by default 1 which means disabled and also in the manual it's not recommended to use it as it would bring arbitrariness; thus in Metatrader versions I didn't even implement it
    • a variable SmLen - this is used in bounded tools NDX, NST and NXC and here it is not just an optional feature but the integral part of the indi, default is 20 for NDX and 10 for NST

     

    So now we can safely assume that whenever NDX/NST/NXC gathers a big move it will probably overshoots. That may be a serious issue since these tools are supposed to mark overbought/oversold area and because of TEMA they may appear in OB/OS even when they in fact shouldn't be there (yet). Therefore now I am trying to replace TEMA with JMA in these and I expect it would give a more accurate picture.

     

    In comparison with many other low lag MAs the TEMA is quite good because the others overshoot too, so I guess that's why Jim and Pat chose TEMA. However JMA is a different league.

     

     

    So far I looked into the code of JMA and RSX and, well, Jurik and Ocean are like each from different world. I wouldn't say one is superior to another. In Jurik the code at the first sight exhibits a signal processing techniques, Mark Jurik definitely knows his stuff very well. If he just would have brought his website into 21st century and made his tools officially available for Metatrader he would be much more famous. But the same is true for Ocean as well. Jim Sloman knows his stuff very well too, but his area is different from Jurik, when he looks at the market he doesn't see a data that should be processed, denoised and smoothed. He has a gift of looking at things from wholly different perspective. Well, as you said, if these two guys united together that would be something.

  4. TEMA - JMA comparison

     

    So I compared JMA with TEMA and a few other low-lag MAs and indeed JMA seems superior to TEMA. TEMA is very fast but the overshooting is the problem. In contrast JMA, even with lower period, is smoother and more accurate. I almost thought it is repainting but there is no such thing in the source code (taken from here: http://www.forex-tsd.com/digital-filters/198-jurik.html).

     

    On the picture the yellow line is JMA with length 4 and phase 50, and blue is TEMA with period 8:

    http://img220.imageshack.us/img220/3235/temajma.png

     

    Original size screenshot:

    http://img690.imageshack.us/img690/3235/temajma.png

     

     

    So yeah, I will think about making JMA an alternative for TEMA in Ocean indis.

  5. hi UDC

    You have done some major and innovative improvements to the ocean software, unfortunately I am not able to take advantage of your work because I am running Tradestation software, I have never considered using Metatrader. What are the advantages of Metrader versus tradestation

     

    Well, as for the features Tradestation is definitely a better and more professional piece of software. Metatrader is very simple and that simplicity and free availability and enormous number of custom indis (and maybe even more enormous number of fraudulent automated trading systems) makes it so popular. Also, Metatrader is order based (as opposite to position based) which makes it better for some cases and worse for other. I personally think you should first consider what broker you want to trade with. Then consider what software is available from that broker and whether it suits you. Even if the software doesn't suit you, there may be a third-party solutions (e.g. Dukascopy doesn't support Metatrader, but there are connectors made by third-party vendors allowing MT4 usage for the fee next to nothing).

     

    Anyway, if you trade manually then you can simply keep using your broker and your broker's software and just run Metatrader (using a free demo available from many brokers, preferably ECN) simultaneously.

  6. hi UDC, Yes you are right the jurik were probably designed for stocks and commodities but I was under the impression that they were also applicable to forex as well. I dont trade forex , I trade commodities but I have noticed that most members here are forex traders. This is the manual for the Jurik tools, they maybe just as good or better than the ocean indicators

    http://www.scribd.com/doc/37296906/Jurik-1

     

    Thank you for the manual, I will check it out.

     

    The Jurik Tools are working for all underlyings.

     

    Sixer

     

    The word "applicable" (as that they indeed can be attached to any kind of chart) might be better fit. There are fundamental differences between forex and other financial markets and indicators which take into account some of those things that are different in both can't logically "work" in both. Typical example is a formula for calculating pivots. I didn't say Jurik indicators don't work as I am not familiar with them yet, I just mentioned that it was my impression those were created not for the forex thus I just expressed a doubt whether they are actually "compatible" with forex. There is quite little talk about Jurik indicators in relation to the forex in the whole forex community.

     

    The best way is to always update on the 1st post and this will be easy for the author to manage and as well as the members to download.

     

    Done.

  7. NDX, NST, NXC et al.

     

    Three bounded Ocean indicators, the first two you already got, the third one is an improved version (thus "x" suffix) of the original with the option to mark zero hits.

     

    Original NDX, NST, NXC on TradeStation:

    http://img705.imageshack.us/img705/7306/ndxnstnxctradestation.png

     

    Ocn_NDX, Ocn_NST, Ocn_NXCx on Metatrader:

    http://img825.imageshack.us/img825/2768/ndxnstnxcmetatrader.png

     

    Original size screenshots:

    http://img802.imageshack.us/img802/7306/ndxnstnxctradestation.png

    http://img402.imageshack.us/img402/2768/ndxnstnxcmetatrader.png

     

     

    However, you don't actually need these three indis at all, because I've combined them all into a single Ocn_NDXNSTNXCx indi, which can:

    • show NDX, NST, NXC
    • show NXC zero hits
    • show a common NDX&NST's NMA
    • turn on/off each of these 5 elements individually (so you can for example show NDX and NXC's zero hits without even showing NXC itself)

     

    As for the NMA, you have 4 options there to adjust it:

    • the period of NMA
    • you can choose whether it should be regular or fast NMA
    • if fast then what would be the minimal lookback
    • pre-smoothing the data before entering NMA

    The default settings is: period 20, regular NMA, pre-smoothing 1 (means no smoothing). As I mentioned I don't know what should be the default settings, I don't even exactly know how this NMA should be calculated from NDX&NST, however after countless studying the videos and testing and trying I found this settings as somewhat, more or less, give or take, remotely similar to what they have. No guarantee (most probably it's not right) :)

     

    Also, I have done another few changes:

    • Ocn_NMA_Price_Osc improved into Ocn_NMA_Price_Oscx: added all SD band lines
    • all indis with SD band lines got a third SD band line in the middle, optional of course
    • when zero hit was detected the SD bands were zeroed; this is now optional and can be turned on/off
    • all indis have versions now

     

    Now the full list of Ocean Classic library (worth $4,995.00) includes:

    1. Ocn_NMAx
    2. Ocn_NMA_Price_Oscx
    3. Ocn_NMA_SD_Band_Osc (orig, keeping this version for compatibility because the improved one got a shifted scale)
    4. Ocn_NMA_SD_Band_Oscx
    5. Ocn_NMA_SD_Band_Width (orig)
    6. Ocn_NMM_X-Ray_1 (orig)
    7. Ocn_NMM_X-Ray_2 (orig, didn't get any idea what to improve on these last three)
    8. Ocn_NMM_Ocean_Indexx
    9. Ocn_NMMx
    10. Ocn_NMM_MACDx
    11. Ocn_NMM_ROCx
    12. Ocn_NMRx
    13. Ocn_NMSx
    14. Ocn_NMCx
    15. Ocn_NMC2x
    16. Ocn_NDX
    17. Ocn_NST
    18. Ocn_NXCx
    19. Ocn_NDXNSTNXCx

     

    Note: I didn't implement all original options and features, namely those functions showing historical overbought/oversold levels etc. They never demonstrated nor commented it in any video so I just haven't found it worth an effort. It can be implemented if needed, though.

     

    http://uloz.to/xeTvGZd/ocn-classic-7z

     

     

    digian: maybe you could make again the "full bundle" package?

     

    Now it's finally time for BTX/STX.

  8. I've implemented the middle SD line in all indis where possible, also some other minor improvements, and combined NDX and NST into a single indi with a common NMA, see the screenshot. The only problem is that I don't know how the NMA is calculated from those two NDX & NST, I have seen this variant only on youtube videos, no source code, so I had to play with it for some time. At the end I left it with some values that seemed somewhat ok and everyone can change it to whatever else.

     

    Anyway, there are indeed places where all 3 lines cross and then start spreading out, Jim is describing those as places with accumulated energy preceding a move. I marked them with white vertical line, just for example.

    I will play with it a bit more, then wrap it up and upload.

     

    http://img692.imageshack.us/img692/4401/ndxnst.png

     

    Original size screenshot:

    http://img861.imageshack.us/img861/4401/ndxnst.png

  9. Grain Trader: hi, well I will need some time to properly answer your question. As for Jurik, I am hearing that name for years but every time I get interested and visit his website the obsolete webdesign which looks like it was created back in 90s totally discourages me. There is even his photo that looks like it was taken not later than in 90s as well, if not earlier. And there is a quote that the cold war is over. Well, yeah, the cold war is over for almost 25 years now. I am not judging the content based on the envelope look, but it just seems to me those algorithms were created for stocks and commodities markets, not for the forex (there is a huge difference there). Could you point out some the "most popular" indicator of his so I could check it out deeply?
  10. Ok, now I will make Ocn_NXC in the original form for reference and the improved Ocn_NXCx version with ZH marking.

    Then I will remake NDX and NST together into an improved Ocn_NDXNSTx with a single NMA of both of them (thus 3 lines in total) - as is Jim showing in this video:

     

    Then it will be time for BTX/STX.

     

    If anyone has any suggestion what to change, improve or add, just say so.

     

    EDIT: I've got another idea - wherever an indicator has the SD bands, add an optional middle SD line, as Pat is showing close to the end of this video:

  11. not I dont want download , my download speed is 20KB/s .

    I will try ask my friend setup server help me download all those video .thx

     

    You don't have to download them, that's what I am telling you - you can watch them online! Check the videobam links I posted before.

     

    As I was downloading I used all of my thank yous and the forum does not let me to thank you anymore!!!

    So here is a very big thank you for all your hard work and help. It has been a pleasure seeing a master who enjoys what he does at work.

    A very BIG HEART FELT THANK YOU.

     

    Thank you, that's kind of you. You are very welcome. Well, you are right, I am a programmer for more than a quarter of century and I still enjoy it very much. The funny thing is I started this thread in hope that someone could access the TSD advanced elite forum and download the indis from there so I don't have to program it myself, and I ended up just doing exactly that :-) The bright side is that because of that I had to go closely through the videos and the manual several times to understand what I am programming so I learnt about it much more than I would otherwise. If I didn't know how NMC/NMC2/NMS and NMA/FastNMA are programmed I most probably wouldn't appreciate them as much as they truly deserve.

  12. Ocn_NST for MT4

     

    Ocn_NST.

     

    Discrepancies from the TradeStation are due to the different price feed, the math is identical. It calculates ranges using highest high and lowest low so the result is highly affected by the spikes and how much the broker averages them.

     

     

    Original Ocn_NST on TradeStation:

    http://img827.imageshack.us/img827/5014/ocnnsttradestation.png

     

    Ocn_NST on Metatrader:

    http://img707.imageshack.us/img707/2519/ocnnstmetatrader.png

     

    Original size screenshots:

    http://img444.imageshack.us/img444/5014/ocnnsttradestation.png

    http://img217.imageshack.us/img217/2519/ocnnstmetatrader.png

     

    #property indicator_separate_window
    #property indicator_buffers 1
    #property indicator_color1 Red
    #property indicator_level1 0
    #property indicator_level2 50
    #property indicator_level3 -50
    #property indicator_levelcolor Gray
    #property indicator_levelstyle 2
    
    extern int NST_period = 20;
    extern int SmLen      = 10;
    
    double NST[];
    double RawNST[];
    
    int init()
    {
     if(SmLen < 5) SmLen = 5;
     else if(SmLen > 15) SmLen = 15;
     string nstname = "NST(" + NST_period + ", " + SmLen + ")";
     IndicatorShortName(nstname);
     IndicatorDigits(0);
     IndicatorBuffers(2);
     SetIndexBuffer(0, NST);
     SetIndexLabel(0, nstname);
     SetIndexBuffer(1, RawNST);
     return(0);
    }
    
    int start()
    {
     int limit, i, ii, counted_bars = IndicatorCounted();
    
     if(Bars <= NST_period + 3*SmLen) return(0);
     if(counted_bars < 0) counted_bars = 0;
     if(counted_bars > NST_period) limit = Bars - counted_bars;
     else                          limit = Bars - NST_period - 1;
    
     for(i = limit; i >= 0; i--)
       {
       double SumWgt = 0, SumDnom = 0, HghAry, LowAry, RngAry, FrcAry, TmeAry, WgtAry;
       for(ii = 0; ii <= NST_period; ii++)
         {
         HghAry = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, ii, i));
         LowAry = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, ii, i));
         RngAry = HghAry - LowAry;
         if(RngAry == 0) FrcAry = 0; else FrcAry = (Close[i] - LowAry) / RngAry;
         TmeAry = 1 / MathPow(ii+1, 0.5);
         WgtAry = TmeAry * FrcAry;
         SumWgt += WgtAry;
         SumDnom += TmeAry;
         }
       RawNST[i] = (200 * SumWgt / SumDnom) - 100;
       }
    
     double ExpSmooth = 2, XAvg1, XAvg2, XAvg3, TemaNST;
     ExpSmooth = ExpSmooth / (SmLen + 1);
     for(i = Bars - NST_period - 1; i >= 0; i--)
       {
       XAvg1 += ExpSmooth * (RawNST[i] - XAvg1);
       XAvg2 += ExpSmooth * (XAvg1 - XAvg2);
       XAvg3 += ExpSmooth * (XAvg2 - XAvg3);
       TemaNST = 3 * XAvg1 - 3 * XAvg2 + XAvg3;
       if(i < Bars - NST_period - 1 - 3*SmLen)
         {
         if(TemaNST > 85) NST[i] = MathRound(85 + (TemaNST - 85) / 2);
         else if(TemaNST < -85) NST[i] = MathRound(-85 - (MathAbs(TemaNST) - 85) / 2);
         else NST[i] = MathRound(TemaNST);
         }
       }
    
     return(0);
    }
    

     

    The source code is also available for download here:

    http://pastebin.com/HECMnLvB

  13. hi barend15 , dont mind teach us how to use it since till now I dont seen any manual teach how to use those indicators .

     

    How come you don't see any manual? What are those 9 DVD videos I posted here? Do you think Pat is telling jokes there? :) All those vids contain nothing but the teaching how to use Ocean software. I even uploaded them to videobam.com so you can directly watch them without any downloading. So stop whining and start learning 8-)

  14. Ocn_NDX for MT4

     

    Here goes Ocn_NDX - first of three bounded Ocean indicators.

     

     

    Original Ocn_NDX on TradeStation:

    http://img18.imageshack.us/img18/4526/ndxtradestation.png

     

    Ocn_NDX on Metatrader:

    http://img269.imageshack.us/img269/4003/ndxmetatrader.png

     

    Original size screenshots:

    http://img138.imageshack.us/img138/4526/ndxtradestation.png

    http://img27.imageshack.us/img27/4003/ndxmetatrader.png

     

    #property indicator_separate_window
    #property indicator_buffers 1
    #property indicator_color1 Red
    #property indicator_level1 0
    #property indicator_level2 50
    #property indicator_level3 -50
    #property indicator_levelcolor Gray
    #property indicator_levelstyle 2
    
    extern int NDX_period = 40;
    extern int SmLen      = 20;
    
    double NDX[];
    double RawNDX[];
    
    int init()
    {
     if(SmLen < 10) SmLen = 10;
     else if(SmLen > 30) SmLen = 30;
     string ndxname = "NDX(" + NDX_period + ")";
     IndicatorShortName(ndxname);
     IndicatorDigits(0);
     IndicatorBuffers(2);
     SetIndexBuffer(0, NDX);
     SetIndexLabel(0, ndxname);
     SetIndexBuffer(1, RawNDX);
     return(0);
    }
    
    int start()
    {
     int limit, i, ii, counted_bars = IndicatorCounted();
    
     if(Bars <= NDX_period + 3*SmLen) return(0);
     if(counted_bars < 0) counted_bars = 0;
     if(counted_bars > NDX_period) limit = Bars - counted_bars;
     else                          limit = Bars - NDX_period - 1;
    
     for(i = limit; i >= 0; i--)
       {
       double SumWght = 0, SumDnom = 0, DifAry, DnomAry, FracAry, TimeAry, WgtAry;
       for(ii = 1; ii <= NDX_period; ii++)
         {
         DifAry = MathLog(Close[i+ii-1]) - MathLog(Close[i+ii]);
         if(ii == 1) DnomAry = MathAbs(DifAry); else DnomAry += MathAbs(DifAry);
         if(DnomAry == 0) FracAry = 0; else FracAry = (MathLog(Close[i]) - MathLog(Close[i+ii])) / DnomAry;
         TimeAry = 1 / MathPow(ii, 0.5);
         WgtAry = FracAry * TimeAry;
         SumWght += WgtAry;
         SumDnom += TimeAry;
         }
       RawNDX[i] = 100 * SumWght / SumDnom;
       }
    
     double ExpSmooth = 2, XAvg1, XAvg2, XAvg3, TemaNDX;
     ExpSmooth = ExpSmooth / (SmLen + 1);
     for(i = Bars - NDX_period - 1; i >= 0; i--)
       {
       XAvg1 += ExpSmooth * (RawNDX[i] - XAvg1);
       XAvg2 += ExpSmooth * (XAvg1 - XAvg2);
       XAvg3 += ExpSmooth * (XAvg2 - XAvg3);
       TemaNDX = 3 * XAvg1 - 3 * XAvg2 + XAvg3;
       if(i < Bars - NDX_period - 1 - 3*SmLen)
         {
         if(TemaNDX > 90) NDX[i] = MathRound(90 + (TemaNDX - 90) / 2);
         else if(TemaNDX < -90) NDX[i] = MathRound(-90 - (MathAbs(TemaNDX) - 90) / 2);
         else NDX[i] = MathRound(TemaNDX);
         }
       }
    
     return(0);
    }
    

     

    The source code is also available for download here:

    http://pastebin.com/DRuAK9GY

  15. resume

     

    Ok, so what I have actually done:

    1. renamed NMA_Price_Osc to Ocn_NMA_Price_Osc
    2. renamed NMA_SD_Band_Width to Ocn_NMA_SD_Band_Width
    3. renamed NMM_X-Ray_1 to Ocn_NMM_X-Ray_1
    4. renamed NMM_X-Ray_2 to Ocn_NMM_X-Ray_2
    5. 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)
    6. improved NMA_SD_Band_Osc into Ocn_NMA_SD_Band_Oscx
    7. improved NMM_Ocean_Index into Ocn_NMM_Ocean_Indexx
    8. improved NMM_ROC into Ocn_NMM_ROCx
    9. improved NMR into Ocn_NMRx
    10. improved NMA and Fast_NMA and combined both into a single Ocn_NMAx
    11. improved NMC and NMC_with_Ocn_MAs and combined both into a single Ocn_NMCx
    12. improved NMC2 and NMC2_with_Ocn_MAs and combined both into a single Ocn_NMC2x
    13. improved NMM and NMM_with_Ocn_MAs and combined both into a single Ocn_NMMx
    14. improved NMM_MACD and NMM_MACD_with_Ocn_MAs and combined both into a single Ocn_NMM_MACDx
    15. 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.

  16. 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

  17. Ocn_NMA_SD_Band_Oscx for MT4

     

    Ocn_NMA_SD_Band_Oscx.

     

    Compared to the original version, there are 2 improvements:

    1. you can display both NMA and FastNMA band oscilators at the same time
    2. 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

  18. 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

  19. 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

  20. 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

  21. 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

×
×
  • Create New...