STARC Bands_v3
Download scriptThe STARCBands indicator is a technical analysis tool designed to help traders visualize price trends and volatility on a financial chart. Rather than simply showing where the price is currently moving, it creates a dynamic "channel" that expands and contracts based on market activity.
Here is a breakdown of how the logic works:
The Core Components
The indicator relies on three primary layers of data to calculate its visual output:
- The Moving Average (The Baseline): The center of the indicator is built using an Exponential Moving Average (EMA). This acts as the "equilibrium" line, smoothing out daily price fluctuations to show the underlying trend. It focuses on recent closing prices to ensure the tool reacts promptly to new information.
- The ATR (Volatility Measurement): To determine how wide the bands should be, the script uses the Average True Range (ATR). This measure calculates how much an asset typically moves in a given timeframe. If the market becomes "choppy" or volatile, the ATR increases; if the market is calm, the ATR decreases.
- The Multiplier: A specific constant (the KATR) is applied to the volatility measurement. This allows the user to decide how sensitive the bands are—essentially choosing how much "breathing room" to give the price before it is considered an outlier.
How the Bands Are Generated
The indicator works by calculating a central path and then projecting a boundary above and below that path:
- Upper Band: The script takes the Moving Average value and adds a product of the volatility (ATR) and the multiplier. This creates a ceiling that follows the trend upward or downward.
- Lower Band: The script takes the Moving Average value and subtracts that same volatility product. This creates a floor.
Practical Behavior on the Chart
Because the bands are tied to both a moving average and a volatility calculation, the resulting visual "tunnel" behaves intelligently:
- In Trending Markets: The entire channel will tilt in the direction of the trend (up or down), helping traders identify the current momentum.
- In High Volatility: When price swings become large and erratic, the bands will widen significantly to accommodate the larger movements.
- In Low Volatility: When the market moves sideways or stays quiet, the bands will tighten, creating a narrower corridor.
By providing this visual framework, the indicator helps traders identify whether the current price action is "normal" relative to recent history or if the price is pushing into extreme territory.
//+------------------------------------------------------------------+
//| STARCBands.mq4 |
//| Copyright © 2005, scorpion@fxfisherman.com |
//| http://www.fxfisherman.com/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, scorpion@fxfisherman.com"
#property link "http://www.fxfisherman.com/"
//----
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Red
//---- indicator parameters
extern int MA_Period=13;
extern int ATR_Period=21;
extern double KATR=1.5;
extern int Shift=1;
extern color UpperColor=Red;
extern color MiddleColor=Red;
extern color LowerColor=Red;
//---- buffers
double MovingBuffer[];
double UpperBuffer[];
double LowerBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_NONE,0,1,MiddleColor);
SetIndexBuffer(0,MovingBuffer);
SetIndexStyle(1,DRAW_LINE,0,3,UpperColor);
SetIndexBuffer(1,UpperBuffer);
SetIndexStyle(2,DRAW_LINE,0,3,LowerColor);
SetIndexBuffer(2,LowerBuffer);
//----
SetIndexDrawBegin(0,MA_Period+Shift);
SetIndexDrawBegin(1,ATR_Period+Shift);
SetIndexDrawBegin(2,ATR_Period+Shift);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Bollinger Bands |
//+------------------------------------------------------------------+
int start()
{
int i,k,counted_bars=IndicatorCounted();
//----
if(Bars<=MA_Period) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=MA_Period;i++)
{
MovingBuffer[Bars-i]=EMPTY_VALUE;
UpperBuffer[Bars-i]=EMPTY_VALUE;
LowerBuffer[Bars-i]=EMPTY_VALUE;
}
//----
int limit=Bars-counted_bars;
if(counted_bars>0) limit++;
for(i=0; i<limit; i++)
{
MovingBuffer[i]=iMA(NULL,0,MA_Period,Shift,MODE_EMA,PRICE_CLOSE,i);
UpperBuffer[i]=MovingBuffer[i] + (KATR * iATR(NULL,0,ATR_Period,i+Shift));
LowerBuffer[i]=MovingBuffer[i] - (KATR * iATR(NULL,0,ATR_Period,i+Shift));
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments