//+------------------------------------------------------------------+ //| BBFibo-VT.mq4 | //| Copyright (c) 2009, Fai Software Corp. | //| http://d.hatena.ne.jp/fai_fx/ | //+------------------------------------------------------------------+ #property copyright "Copyright (c) 2009, Fai Software Corp." #property link "http://d.hatena.ne.jp/fai_fx/" #property indicator_chart_window #property indicator_buffers 7 #property indicator_color1 C'000,127,127' #property indicator_color2 C'000,127,000' #property indicator_color3 C'127,127,000' #property indicator_color4 Red #property indicator_color5 C'127,127,000' #property indicator_color6 C'000,127,000' #property indicator_color7 C'000,127,127' #property indicator_width1 2 #property indicator_width7 2 #property indicator_style3 STYLE_DOT #property indicator_style5 STYLE_DOT //---- input parameters extern int MAPeriod= 20; extern double factor1 = 1.618; extern double factor2 = 2.618; extern double factor3 = 4.236; //---- buffers double UpperBand3[]; double UpperBand2[]; double UpperBand1[]; double MidPoint[]; double LowerBand1[]; double LowerBand2[]; double LowerBand3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,UpperBand3); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,UpperBand2); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,UpperBand1); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,MidPoint); SetIndexStyle(4,DRAW_LINE); SetIndexBuffer(4,LowerBand1); SetIndexStyle(5,DRAW_LINE); SetIndexBuffer(5,LowerBand2); SetIndexStyle(6,DRAW_LINE); SetIndexBuffer(6,LowerBand3); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ /* TH:=If(Ref(C,-1) > H,Ref(C,-1),H); TL:=If(Ref(C,-1) < L,Ref(C,-1),L); TR:=TH-TL; TRA:= Wilders(TR,Periods); UpperBand3:=Mov( C, Periods, S) + ( factor3 * TRa); UpperBand2:=Mov( C, Periods, S) + ( factor2 * TRa); UpperBand1:=Mov( C, Periods, S) + ( factor1 * TRa); MidPoint:=Mov(C, Periods, S); LowerBand1:=Mov( C, Periods, S) - ( factor1 * TRa); LowerBand2:=Mov( C, Periods, S) - ( factor2 * TRa); LowerBand3:=Mov( C, Periods, S) - ( factor3 * TRa); */ int start() { int counted_bars=IndicatorCounted(); //---- double TRBuffer[]; ArraySetAsSeries(TRBuffer,true); ArrayResize(TRBuffer,Bars); for(int i=0;i0) counted_bars--; int limit=Bars-1-counted_bars; for(i=0; i<=limit; i++){ double TRa = iMAOnArray(TRBuffer,Bars,MAPeriod*2-1,0,MODE_EMA,i); MidPoint[i] = iMA(NULL,0,MAPeriod,0,MODE_SMA,PRICE_CLOSE,i); UpperBand3[i]= MidPoint[i] + factor3 * TRa; UpperBand2[i]= MidPoint[i] + factor2 * TRa; UpperBand1[i]= MidPoint[i] + factor1 * TRa; LowerBand1[i]= MidPoint[i] - factor1 * TRa; LowerBand2[i]= MidPoint[i] - factor2 * TRa; LowerBand3[i]= MidPoint[i] - factor3 * TRa; } return(0); } //+------------------------------------------------------------------+