//+------------------------------------------------------------------+ //| MAPlusMinus.mq4 | //| John Taylor | //| http://www.linkedin.com/in/johntaylorhk | //+------------------------------------------------------------------+ #property copyright "John Taylor" #property link "http://www.linkedin.com/in/johntaylorhk" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Lime #property indicator_color2 Red #property indicator_color3 Magenta #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 1 extern int E_Period =12; extern int E_PlusPts = 5; extern int E_MinusPts = 5; /* MODE_SMA 0 Simple moving average, MODE_EMA 1 Exponential moving average, MODE_SMMA 2 Smoothed moving average, MODE_LWMA 3 Linear weighted moving average */ extern int E_MaType = MODE_SMA; /* PRICE_CLOSE 0 Close price. PRICE_OPEN 1 Open price. PRICE_HIGH 2 High price. PRICE_LOW 3 Low price. PRICE_MEDIAN 4 Median price, (high+low)/2. PRICE_TYPICAL 5 Typical price, (high+low+close)/3. PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4. */ extern int E_PriceType = PRICE_CLOSE; // double ma[]; double plus[]; double minus[]; double myPoint; // Robert added for better handling of 4 and 5 digit brokers int init() { IndicatorShortName(StringConcatenate("MAPlusMinus(+",E_PlusPts,"/-",E_MinusPts,")")); SetIndexBuffer(0,plus); SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,1,Lime); SetIndexLabel (0,"Upper"); SetIndexBuffer(1,minus); SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,1,Red); SetIndexLabel (1,"Lower"); SetIndexBuffer(2,ma); SetIndexStyle (2,DRAW_LINE,STYLE_SOLID,1,Magenta); SetIndexLabel (2,"Middle"); SetIndexDrawBegin(0,E_Period-1); SetIndexDrawBegin(1,E_Period-1); SetIndexDrawBegin(2,E_Period-1); myPoint = SetPoint(); return(0); } int deinit() { return(0); } int start() { if (Bars=0;shift--) { ma[shift]=iMA(NULL,0,E_Period,0,E_MaType,E_PriceType,shift); plus[shift]=ma[shift]+E_PlusPts*myPoint; // Modified Point to myPoint for 5 digit brokers minus[shift]=ma[shift]-E_PlusPts*myPoint; } return(0); } double SetPoint() { double mPoint; if (Digits < 4) mPoint = 0.01; else mPoint = 0.0001; return(mPoint); }