Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #property indicator_separate_window
- #property indicator_minimum 0
- #property indicator_maximum 40
- #property indicator_buffers 3
- #property indicator_color1 Red
- #property indicator_color2 Blue
- #property indicator_color3 Aqua
- #property indicator_level1 0
- #property indicator_level2 20
- #property indicator_levelcolor Gray
- #property indicator_levelstyle 2
- extern int NMM_period = 40;
- extern bool Show_value = false;
- extern bool Show_LB = true;
- double NMMmaxratio[];
- double NMMsign[];
- double LBlen[];
- int init()
- {
- string nmmname = "NMM_X-Ray_2";
- IndicatorShortName(nmmname + "(" + NMM_period + ")");
- if(Show_value) IndicatorDigits(2); else IndicatorDigits(0);
- IndicatorBuffers(3);
- SetIndexBuffer(0, NMMmaxratio);
- SetIndexLabel(0, nmmname + "(" + NMM_period + ")");
- SetIndexBuffer(1, NMMsign);
- SetIndexLabel(1, nmmname + "_sign");
- SetIndexBuffer(2, LBlen);
- SetIndexLabel(2, nmmname + "_LBlen");
- return(0);
- }
- int start()
- {
- int limit, i, ii, counted_bars = IndicatorCounted();
- 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--)
- {
- double nmmnum, nmmmax = -1, nmmsign, nmmlb;
- for(ii = 1; ii <= NMM_period; ii++)
- {
- nmmnum = (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii);
- if(MathAbs(nmmnum) > nmmmax)
- {
- nmmmax = MathAbs(nmmnum);
- nmmlb = ii;
- if(nmmnum > 0) nmmsign = 1;
- else if(nmmnum < 0) nmmsign = -1;
- else nmmsign = 0;
- }
- }
- if(Show_value) { NMMmaxratio[i] = nmmmax * 1000; NMMsign[i] = nmmsign; }
- if(Show_LB) LBlen[i] = nmmlb;
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement