//+------------------------------------------------------------------+ //| BBflat_sw.mq4 | //|mtf 2007forextsd +BBSqueeze ki by Raff | //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 Aqua #property indicator_color2 Red #property indicator_color3 Red #property indicator_color4 Yellow #property indicator_color5 BlueViolet #property indicator_levelcolor SlateGray #property indicator_level1 0.0004 #property indicator_level2 -0.0004 extern int TimeFrame=0; extern int period=20; extern int method=0; extern int price=0; extern double deviation=2; extern int shift=0; extern int MaxBarsToCount = 1500; extern double SqzSigLevel = -0.0006; // bbsqueeze extern int SqzbolPrd = 20; extern double SqzbolDev = 2.0; extern int SqzkeltPrd = 20; extern double SqzkeltFactor= 1.5; extern string note_Price = "0C1O 2H3L 4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6"; extern string MA_Method = "SMA0 EMA1 SMMA2 LWMA3"; extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN"; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; double upK[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,ExtMapBuffer4); SetIndexStyle(4,DRAW_ARROW,EMPTY); SetIndexBuffer(4,upK); SetIndexEmptyValue(4,EMPTY_VALUE); SetIndexArrow(4,159); SetIndexLabel(0,""); SetIndexLabel(1,"Std"+deviation+""); SetIndexLabel(2,""); SetIndexLabel(3,""); SetIndexLabel(4,""); //---- switch(TimeFrame) { case 1 : string TimeFrameStr= "M1"; break; case 5 : TimeFrameStr= "M5"; break; case 15 : TimeFrameStr= "M15"; break; case 30 : TimeFrameStr= "M30"; break; case 60 : TimeFrameStr= "H1"; break; case 240 : TimeFrameStr= "H4"; break; case 1440 : TimeFrameStr= "D1"; break; case 10080 : TimeFrameStr= "W1"; break; case 43200 : TimeFrameStr= "MN1"; break; default : TimeFrameStr= "CurrTF"; } IndicatorShortName("BBFlat ("+period+";"+deviation+") ["+TimeFrameStr+"]"); if (TimeFrame < Period()) TimeFrame = Period(); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { datetime TimeArray[]; int i,limit,y=0,counted_bars=IndicatorCounted(); ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); double ima, std; double diff,d,dPrev, Std,bbs; if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit = Bars-counted_bars; limit = MathMax (limit,TimeFrame/Period()); limit= MathMin(limit,MaxBarsToCount); for(i=0,y=0;i<limit;i++) { if (Time[i]<TimeArray[y]) y++; ima=iMA(NULL,TimeFrame,period,0,method,price,y); std=deviation*iStdDev(NULL,TimeFrame,period,0,method,price,y); ExtMapBuffer1[i]=0; ExtMapBuffer2[i]=std; ExtMapBuffer3[i]=-std; ExtMapBuffer4[i]=iClose(NULL,TimeFrame,y)-ima; //// diff = iATR(NULL,TimeFrame,SqzkeltPrd,y)*SqzkeltFactor; Std = iStdDev(NULL,TimeFrame,SqzbolPrd,MODE_SMA,0,PRICE_CLOSE,y); bbs = SqzbolDev * Std / diff; if(bbs<1) { if (ExtMapBuffer4[i]>0) upK[i]= SqzSigLevel; else upK[i]= -SqzSigLevel; } else { upK[i]=EMPTY_VALUE; } //// } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_ARROW
Indicators Used:
Moving average indicator
Standard Deviation indicator
Indicator of the average true range
Custom Indicators Used:
Order Management characteristics:
Other Features: