Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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_LB = 21;
- extern bool Show_SD = true;
- extern int SD_len = 30;
- extern double SD_up = 2;
- extern double SD_dn = 2;
- double NMM[];
- double SD[];
- int init()
- {
- string nmmname = "NMM_Ocean_Index(" + NMM_LB + ")";
- string sdname = "NMM_Ocean_Index_SD(" + SD_len + ")";
- IndicatorShortName(nmmname);
- IndicatorBuffers(2);
- SetIndexBuffer(0, NMM);
- SetIndexLabel(0, nmmname);
- SetIndexBuffer(1, SD);
- SetIndexLabel(1, sdname);
- return(0);
- }
- int start()
- {
- int limit, i, counted_bars = IndicatorCounted();
- 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_SD)
- for(i = limit; i >= 0; i--)
- if(i < Bars - NMM_LB - 1 - SD_len)
- {
- 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);
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement