//+------------------------------------------------------------------------+ //|Banzai Dynamic Zone RSI(FL BBL mtf).mq4 | //|FiboLevels BollingerBandLevels Copyright © 2005-07, Pavel Kulko. | //|(MTF ForexTSD.com 2007) mladen ki polk@alba.dp.ua | //+------------------------------------------------------------------------+ //2008fxtsd update ki #property copyright "Copyright © 2005-07, Pavel Kulko" #property link "polk@alba.dp.ua" #property indicator_buffers 7 #property indicator_color1 SlateGray //upper band #property indicator_color2 DarkSlateGray //upper band1 FL 0.382/0.618 #property indicator_color3 Red // BB median line #property indicator_color4 DarkSlateGray //lower band1 FL 0.382/0.618 #property indicator_color5 SlateGray //lower band #property indicator_color6 Blue // SigMA 0=sma,1=ema,2=smma,3=lwma #property indicator_color7 Lime //RSI #property indicator_width6 2 #property indicator_style2 2 //STYLE_SOLID=0;DASH=1;DOT=2;DASHDOT=3;DASHDOTDOT=4; #property indicator_style4 2 #property indicator_level1 76.4 #property indicator_level2 61.8 #property indicator_level3 50.0 #property indicator_level4 38.2 #property indicator_level5 23.6 #property indicator_levelcolor DarkOliveGreen #property indicator_separate_window extern int RSI_Period = 13; extern int SigMA_Period = 5; extern int SigMA_Mode = 1; //0=sma,1=ema,2=smma,3=lwma; extern int Band_Period = 18; extern int timeFrame = 0; extern string note_timeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN"; extern string ________MA_Mode = "SMA0 EMA1 SMMA2 LWMA3"; string IndicatorFileName; double RSIBuf[], SigMABuf[]; double MABuf[],UpZone[],DnZone[],UpZone1[],DnZone1[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexStyle(2,DRAW_LINE); SetIndexStyle(3,DRAW_LINE); SetIndexStyle(4,DRAW_LINE); SetIndexStyle(5,DRAW_LINE); SetIndexStyle(6,DRAW_LINE); SetIndexBuffer(0,UpZone); SetIndexBuffer(1,UpZone1); SetIndexBuffer(2,MABuf); SetIndexBuffer(3,DnZone1); SetIndexBuffer(4,DnZone); SetIndexBuffer(5,SigMABuf); SetIndexBuffer(6,RSIBuf); timeFrame = MathMax(timeFrame,Period()); 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 = "TF0"; } //---- name for DataWindow and indicator subwindow label IndicatorShortName("DynamicZone_RSI ["+TimeFrameStr+"] RSI ("+RSI_Period+") SigMA ("+SigMA_Period+") BB ("+Band_Period+") "); IndicatorFileName = WindowExpertName(); //---- SetIndexLabel(0,""); SetIndexLabel(1,""); SetIndexLabel(2,"MA"); SetIndexLabel(3,""); SetIndexLabel(4,""); SetIndexLabel(5,"SigMA"); SetIndexLabel(3,"RSI"); return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { double MA, RSI[]; ArrayResize(RSI,Band_Period); //-- int i,limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit = Bars-counted_bars; // // // MTF mode operating // // if (timeFrame != Period()) { limit = MathMax(limit,timeFrame/Period()); datetime TimeArray[]; ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,timeFrame); // // // // // for(i=0,int y=0; i<limit; i++) { if(Time[i]<TimeArray[y]) y++; UpZone[i] = iCustom(NULL,timeFrame,IndicatorFileName, RSI_Period,SigMA_Period,SigMA_Mode,Band_Period,0,y); UpZone1[i] = iCustom(NULL,timeFrame,IndicatorFileName, RSI_Period,SigMA_Period,SigMA_Mode,Band_Period,1,y); MABuf[i] = iCustom(NULL,timeFrame,IndicatorFileName, RSI_Period,SigMA_Period,SigMA_Mode,Band_Period,2,y); DnZone1[i] = iCustom(NULL,timeFrame,IndicatorFileName, RSI_Period,SigMA_Period,SigMA_Mode,Band_Period,3,y); DnZone[i] = iCustom(NULL,timeFrame,IndicatorFileName, RSI_Period,SigMA_Period,SigMA_Mode,Band_Period,4,y); SigMABuf[i] = iCustom(NULL,timeFrame,IndicatorFileName, RSI_Period,SigMA_Period,SigMA_Mode,Band_Period,5,y); RSIBuf[i] = iCustom(NULL,timeFrame,IndicatorFileName, RSI_Period,SigMA_Period,SigMA_Mode,Band_Period,6,y); } return(0); } // // // // // //-- for(i=limit; i>=0; i--) { RSIBuf[i] = iRSI(NULL,0,RSI_Period,PRICE_WEIGHTED,i); MA = 0; for(int j=i; j<i+Band_Period; j++) { RSI[j-i] = RSIBuf[j]; MA += RSIBuf[j]/Band_Period; } UpZone[i] = MA + (1.3185 * StDev(RSI,Band_Period)); DnZone[i] = MA - (1.3185 * StDev(RSI,Band_Period)); UpZone1[i] = MA + (0.382 * StDev(RSI,Band_Period)); DnZone1[i] = MA - (0.382 * StDev(RSI,Band_Period)); MABuf[i] = MA; } for (i=limit; i>=0; i--) SigMABuf[i] = iMAOnArray (RSIBuf,0,SigMA_Period,0,SigMA_Mode,i); return(0); } double StDev(double& Data[], int Per) { return(MathSqrt(Variance(Data,Per))); } double Variance(double& Data[], int Per) { double sum, ssum; for (int i=0; i<Per; i++) { sum += Data[i]; ssum += MathPow(Data[i],2); } return((ssum*Per - sum*sum)/(Per*(Per-1))); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Relative strength index
Custom Indicators Used:
Order Management characteristics:
Other Features: