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 Yellow
- #property indicator_color2 CLR_NONE
- #property indicator_color3 CLR_NONE
- #property indicator_level1 20
- #property indicator_levelcolor Gray
- #property indicator_levelstyle 2
- extern int NMM_period = 40;
- extern bool Show_Pct = false;
- double NMM[];
- double NegCnt[];
- double ZeroCnt[];
- int init()
- {
- string nmmname = "NMM_X-Ray_1";
- IndicatorShortName(nmmname + "(" + NMM_period + ")");
- IndicatorBuffers(3);
- SetIndexBuffer(0, NMM);
- SetIndexLabel(0, nmmname + "(" + NMM_period + ")");
- SetIndexBuffer(1, NegCnt);
- SetIndexLabel(1, nmmname + "_NegCnt");
- SetIndexBuffer(2, ZeroCnt);
- SetIndexLabel(2, nmmname + "_ZeroCnt");
- 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, Pos = 0, Neg = 0, Zero = 0;
- for(ii = 1; ii <= NMM_period; ii++)
- {
- nmmnum = (MathLog(Close[i]) - MathLog(Close[i+ii])) / MathSqrt(ii);
- if(nmmnum > 0) Pos++;
- else if(nmmnum < 0) Neg++;
- else Zero++;
- }
- if(Show_Pct)
- {
- NMM[i] = Pos / NMM_period * 100;
- NegCnt[i] = Neg / NMM_period * 100;
- ZeroCnt[i] = Zero / NMM_period * 100;
- }
- else
- {
- NMM[i] = Pos;
- NegCnt[i] = Neg;
- ZeroCnt[i] = Zero;
- }
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement