Accrete-ATM_TunnelBands
Download scriptThis script is a specialized technical analysis tool designed to provide traders with a visual representation of price momentum and volatility. It modifies the standard Bollinger Bands concept into a custom framework tailored for the Accrete Trading Model, helping users identify specific market structures and potential entry points.
Core Logic and Functionality
The script functions by analyzing historical price data to create several distinct layers of information on the trading chart:
1. Primary Trend Foundations (Moving Averages) The tool begins by calculating three different types of Exponential Moving Averages (EMAs). Unlike standard averages that only look at closing prices, some of these calculations focus specifically on the "Highs" and "Lows" of price action over a long duration (144 periods). Others track the "Closing" prices over shorter durations (12 and 24 periods). These serve as the backbone of the indicator, helping to smooth out market "noise" and highlight the prevailing direction of the trend.
2. Dynamic Volatility Tunneling The most unique aspect of this script is how it constructs its price bands. Instead of using a simple standard deviation of the closing price, it measures the variance between the actual market Closing Price and the long-term Low Price of the asset.
By calculating this specific relationship, the script generates two sets of dynamic bands:
- Inner Bands: These represent a tighter range of volatility based on a 1.00 multiplier. They help identify short-term fluctuations within a larger trend.
- Middle Bands: These represent a wider range of volatility using a 2.00 multiplier, providing a broader perspective on the market's "stretch."
3. Visual Output The script renders these calculations onto the chart as a series of lines and buffers. By observing where the current price sits in relation to these various moving averages and volatility bands (the "Tunnel"), traders can visually assess whether the market is overextended, consolidating, or beginning a new trend cycle.
Summary for the User
In plain terms, this script doesn't just tell you what the price is doing now; it maps out the "boundaries" of where the price has historically behaved. It provides a multi-layered visual environment that helps distinguish between significant trend shifts and minor market fluctuations by focusing on the relationship between high/low extremes and the recent closing prices.
/*+~><>~~~~~~~~~~~~~~~~~~~~~~><>~~~~~~~~~~~~~~~~~~~~~~><>~~~~~~~~~~~~~~~~~~~~~~+
| |
| 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);
}
//+------------------------------------------------------------------+
Comments