Squeeze Straddle
Download scriptThis script is designed as a visual tool for traders to identify specific market conditions where price action might be preparing for a significant move. Rather than making automated trades, it analyzes historical price data to highlight "squeezes"—periods of low volatility that often precede sudden breakouts.
How the Logic Works
The script operates by monitoring three primary components of market behavior:
1. Volatility and Standard Deviation Analysis The tool constantly compares two different types of market movement:
- Average True Range (ATR): This measures how much the price moves on average over a short period.
- Standard Deviation: This measures how much the price fluctuates from its recent average. By calculating the ratio between these two, the script can determine if the market is "tightening" or "squeezing." When the volatility drops below a specific threshold relative to the typical movement, it indicates that the market is becoming compressed.
2. Trend Identification (The Clouds) The script tracks two different Moving Averages (short-term and long-term) to visualize the current trend.
- The Short-term average reacts quickly to price changes.
- The Long-term average provides a smoother picture of the overall direction. The interaction between these two averages helps the user see whether the market is currently in an uptrend, downtrend, or moving sideways.
3. The "Squeeze" Detection The core logic focuses on identifying moments where the market's internal pressure is building. It looks for specific mathematical conditions where the "squeeze" value for one timeframe becomes lower than another. Essentially, it flags instances where the price is being pushed into a very narrow range, suggesting that an expansion (a breakout) could occur in either direction soon.
Summary for the User
Think of this indicator as a "pressure gauge." It monitors how much the market is vibrating. When the vibrations become unusually small while the price remains compressed between two trend lines, the script identifies a potential "Squeeze." Traders use these visual cues to anticipate high-momentum moves, allowing them to prepare for a breakout once the market finally releases that built-up tension.
//+------------------------------------------------------------------+
//| Squeeze Straddle.mq4 |
//| Copyright © 2006, Akuma99. |
//| http://www.beginnertrader.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Akuma99."
#property link "http://www.beginnertrader.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Green
extern int distance=20;
extern int totalBars=3000;
extern int bolPrd=12;
extern double bolDev=2.0;
extern int keltPrd=6;
extern double keltFactor=1;
extern bool emailAlert=false;
double upK[];
double loK[];
double clouds1[];
double clouds2[];
int init() {
SetIndexStyle(0,DRAW_LINE,EMPTY,1,indicator_color1);
SetIndexBuffer(0,upK);
SetIndexStyle(1,DRAW_LINE,EMPTY,1,indicator_color2);
SetIndexBuffer(1,loK);
SetIndexStyle(2,DRAW_HISTOGRAM, 2, 1, indicator_color3);
SetIndexBuffer(2, clouds1);
SetIndexStyle(3,DRAW_HISTOGRAM, 2, 1, indicator_color4);
SetIndexBuffer(3, clouds2);
return(0);
}
int start() {
int counted_bars=IndicatorCounted();
int shift,limit;
double diff1,std1,bbs1,diff2,std2,bbs2,dis,ema1,ema2;
if (counted_bars<0) return(-1);
limit=totalBars;
dis = iATR(NULL,0,24,shift)*1.5;
for (shift=limit;shift>=0;shift--) {
diff1 = iATR(NULL,0,keltPrd,shift)*keltFactor;
std1 = iStdDev(NULL,0,bolPrd,MODE_SMA,0,PRICE_CLOSE,shift);
bbs1 = bolDev * std1 / diff1;
diff2 = iATR(NULL,0,keltPrd,shift+1)*keltFactor;
std2 = iStdDev(NULL,0,bolPrd,MODE_SMA,0,PRICE_CLOSE,shift+1);
bbs2 = bolDev * std2 / diff2;
ema1 = iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,shift);
ema2 = iMA(NULL,0,50,0,MODE_EMA,PRICE_CLOSE,shift);
clouds1[shift] = ema1;
clouds2[shift] = ema2;
Print ("clouds = ", ema2);
if(bbs1 < 1 && bbs2 > 1) {
//upK[shift]=Close[shift+1]+dis;
//loK[shift]=Close[shift+1]-dis;
} else {
//upK[shift] = upK[shift+1];
//loK[shift] = loK[shift+1];
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments