BB_Sqz_sBar_mtf_sw
Download scriptThis technical script is designed to act as a market analysis tool that identifies periods of low volatility, often referred to as "squeezes." By monitoring price action, the indicator helps traders spot moments where the market is consolidating before a potential breakout.
Core Logic and Functionality
The script operates by comparing two different types of market movement data: volatility and standard deviation. Here is how it processes this information to provide visual signals:
- Volatility Measurement: The tool looks at a specific range of price movement (based on the Keltner Period settings) to determine how much the price has been "swinging" recently.
- Price Dispersion: It simultaneously calculates the standard deviation, which measures how far the price is straying from its average movement over a set period.
- The Squeeze Calculation: The script divides the price dispersion by the volatility measurement. This creates a ratio that represents the relationship between current "noise" and actual price range.
How it Signals the Market
The primary goal of this script is to detect when the market is becoming unusually compressed.
- Identification: When the calculated ratio falls below a specific threshold (the "Squeeze"), it indicates that the price movement is tighter than normal relative to its recent history.
- Visual Output: Instead of drawing a complex line, the indicator places a specific symbol (an arrow) on your chart during these low-volatility periods.
- Interpretation: When you see these markers appearing, it suggests that the market is "coiling" like a spring. Traders typically use this information to prepare for a significant move, as squeezed markets are often followed by a sharp expansion in price in one direction or the other.
Key Features for the User
- Multi-Timeframe Awareness: The script can be configured to look at higher timeframes (like Hourly or Daily) while you are viewing lower ones, ensuring that you are aware of the broader market context.
- Customizable Sensitivity: Users can adjust the periods and factors to make the indicator more "sensitive" (identifying smaller squeezes) or "relaxed" (identifying only major market consolidations).
- Efficiency: The script is designed to limit the amount of historical data it processes at once, ensuring that the platform remains responsive while still providing accurate real-time updates.
//+------------------------------------------------------------------+
//| bbsqueeze.mq4 |
//| Copyright © 2005, Nick Bilak, beluck[AT]gmail.com |
//|BBSqz sidebar(overlay) keris f-la mtf |
//+------------------------------------------------------------------+
//2008fxtsd ki
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Gold
#property indicator_width1 2
#property indicator_maximum 77
#property indicator_minimum 1
extern int TimeFrame=0;
extern int BolPrd = 20;
extern int BolMethod = 0;
extern int BolPrice = 0;
extern double BolDev = 2.0;
extern int KeltPrd = 20;
extern double KeltFactor = 1.5;
extern int SqzBarLevel = 5;
extern int MaxBarsToCount = 1500;
extern string note_Price = "0C1O 2H3L 4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
extern string MA_Method = "SMA0 EMA1 SMMA2 LWMA3";
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN";
double ExtMapBuffer1[];
//+------
int init()
{
SetIndexStyle(0,DRAW_ARROW,EMPTY);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,EMPTY_VALUE);
SetIndexArrow(0,158);//159
SetIndexLabel(0,"BBSqz");
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";
}
IndicatorShortName("BBSqz sB("+BolPrd+","+DoubleToStr(BolDev,2)+") ("+KeltPrd+","+DoubleToStr(KeltFactor,2)+") ["+TimeFrameStr+"] ");
return(0);
}
//+---------
int start()
{
datetime TimeArray[];
int i,y,limit,counted_bars=IndicatorCounted();
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
double diff, std,bbs;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit = Bars-counted_bars;
limit = MathMax (limit,TimeFrame/Period());
limit = MathMin (limit,MaxBarsToCount);
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;
diff = iATR(NULL,TimeFrame,KeltPrd,y)*KeltFactor;
std = iStdDev(NULL,TimeFrame,BolPrd,BolMethod,0,BolPrice,y);
if (diff != 0)
bbs = BolDev * std / diff;
else bbs = 0;
if(bbs<1) ExtMapBuffer1[i]= SqzBarLevel;
else ExtMapBuffer1[i]= EMPTY_VALUE;
}
return(0);
}
//+------------------------------------------------------------------+
Comments