/*+~><>~~~~~~~~~~~~~~~~~~~~~~><>~~~~~~~~~~~~~~~~~~~~~~><>~~~~~~~~~~~~~~~~~~~~~~+ | | | Copyright © 2006, Accrete LLC | | http://www.accrete.com | | For further information on the Accrete Trading Model", | | visit the web at www.accrete.com/fx-atm . There you will find various | | links, trade examples, and the latest updates on the model by Accrete | +~><>~~~~~~~~~~~~~~~~~~~~~~><>~~~~~~~~~~~~~~~~~~~~~~><>~~~~~~~~~~~~~~~~~~~~~~+ */ #property copyright "Bollinger Band Indicator hack by Accrete for use in the Accrete trading model" #property link "http://www.accrete.com/" #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 Magenta #property indicator_color2 Magenta #property indicator_color3 Black #property indicator_color4 Black #property indicator_color5 Black #property indicator_color6 Black #property indicator_color7 Yellow #property indicator_color8 Lime //---- indicator parameters int BandsPeriod=144; double InnerBand=1.00; double MiddleBand=2.00; int BandsShift=0; //---- buffers double TunnelHighBuffer[]; double TunnelLowBuffer[]; double InUpBuffer[]; double InDnBuffer[]; double MidUpBuffer[]; double MidDnBuffer[]; double MA24Buffer[]; double MA12Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE,2,0); SetIndexBuffer(0,TunnelHighBuffer); SetIndexStyle(1,DRAW_LINE,2,0); SetIndexBuffer(1,TunnelLowBuffer); SetIndexStyle(2,DRAW_LINE,2,0); SetIndexBuffer(2,InUpBuffer); SetIndexStyle(3,DRAW_LINE,2,0); SetIndexBuffer(3,InDnBuffer); SetIndexStyle(4,DRAW_LINE,2,0); SetIndexBuffer(4,MidUpBuffer); SetIndexStyle(5,DRAW_LINE,2,0); SetIndexBuffer(5,MidDnBuffer); SetIndexStyle(6,DRAW_LINE,0,1); SetIndexBuffer(6,MA24Buffer); // SetIndexStyle(7,DRAW_ARROW,0,1); SetIndexStyle(7,DRAW_LINE,0,1); SetIndexBuffer(7,MA12Buffer); // SetIndexArrow(7,160); // (160 original dot shape, 115 or 108 for larger dots, and 110 or 111 for squares,116 diamond) //----draw bands: SetIndexDrawBegin(2,BandsPeriod+BandsShift); SetIndexDrawBegin(3,BandsPeriod+BandsShift); SetIndexDrawBegin(4,BandsPeriod+BandsShift); SetIndexDrawBegin(5,BandsPeriod+BandsShift); //---- return(0); } //+------------------------------------------------------------------+ //| Bollinger Bands | //+------------------------------------------------------------------+ int start() { int i,k,counted_bars=IndicatorCounted(); double deviation; double deviation2; double sum,oldval,newres; //---- if(Bars<=BandsPeriod) return(0); //---- initial zero if(counted_bars<1) for(i=1;i<=BandsPeriod;i++) { TunnelHighBuffer[Bars-i]=EMPTY_VALUE; TunnelLowBuffer[Bars-i]=EMPTY_VALUE; InUpBuffer[Bars-i]=EMPTY_VALUE; InDnBuffer[Bars-i]=EMPTY_VALUE; MidUpBuffer[Bars-i]=EMPTY_VALUE; MidDnBuffer[Bars-i]=EMPTY_VALUE; } //----open ma int limit=Bars-counted_bars; if(counted_bars>0) limit++; for(i=0; i<limit; i++) //----draw long term and short term moving averages: TunnelHighBuffer[i]=iMA(NULL,0,144,0,MODE_EMA,PRICE_HIGH,i); if(counted_bars>0) limit++; for(i=0; i<limit; i++) TunnelLowBuffer[i]=iMA(NULL,0,144,0,MODE_EMA,PRICE_LOW,i); if(counted_bars>0) limit++; for(i=0; i<limit; i++) MA24Buffer[i]=iMA(NULL,0,24,0,MODE_EMA,PRICE_CLOSE,i); if(counted_bars>0) limit++; for(i=0; i<limit; i++) MA12Buffer[i]=iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,i); //----band ma data i=Bars-BandsPeriod+1; if(counted_bars>BandsPeriod-1) i=Bars-counted_bars-1; while(i>=0) { sum=0.0; k=i+BandsPeriod-1; oldval=TunnelLowBuffer[i]; while(k>=i) { newres=Close[k]-oldval; sum+=newres*newres; k--; } deviation=InnerBand*MathSqrt(sum/BandsPeriod); InUpBuffer[i]=oldval+deviation; InDnBuffer[i]=oldval-deviation; deviation2=MiddleBand*MathSqrt(sum/BandsPeriod); MidUpBuffer[i]=oldval+deviation2; MidDnBuffer[i]=oldval-deviation2; i--; } //---- Comment("Accrete Trading Model", "\naccrete.com/fx-atm" ); return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: