Volatility Breakout Expert Advisor and Squeeze Indicator

.mq4 file for $99

This Expert Advisor in .mq4 format has fully commented code to let you test, customize, and automate the Bollinger Band squeeze, also known as a volatility breakout, in MetaTrader 4. As volatility goes down and the price range compresses, prices can then tend to breakout to higher volatility. By only entering positions when the BandWidth is close to its low and confirming with a Bollinger Band breakout, this expert advisor attempts to capture trends as they take off. Exits occur when the price goes back to the middle moving average. Our Bollinger BandWidth indicator is available free at the MQL Market. Our BandWidth Squeeze indicator is included with this EA to see when the BandWidth compresses and you potentially have a squeeze. The headfake is what John Bollinger calls a squeeze with a breakout to one band that head fakes or whipsaws to the opposite band before starting a trend.

A quick visual example to show approximate entry and exit areas (arrows manually added):
Volatility Breakout EA Example
Note: The default input values are not optimized. Demo the EA for free or buy a compiled version (.ex4 file - cannot see or modify the EA code) at the MQL Market. Adjust the inputs to find the optimized combination for your risk tolerance and to maximize profitability. Trend Following systems are designed around long term probabilities. Although Trend Following systems have lower win rates, profitability comes from large trends as Trend Following cuts losses short and lets winners run. Test on a portfolio of symbols as profits from trending symbols will offset the small losses and provide profits when other symbols are not trending.

Customizable Variables


Trade on any pair and any timeframe. Place the expert advisor on a chart and it will use the currency pair and timeframe of the chart. Choppy and sideways markets will cause more whipsaws while markets that trend will produce more profitable trades.


To find a Bollinger Band squeeze, this Expert Advisor calculates the lowest BandWidth of the number of bars you specify. You then specify a percentage threshold above that lowest BandWidth to create your entry criteria. Entries occur when the prior bar's BandWidth is within your threshold and the price goes outside of either the upper or lower Bollinger Band. If your threshold is 20% of the lowest BandWidth, long positions are entered when the price equals or goes above the upper Bollinger Band and the BandWidth is less than 120% of the lowest BandWidth. Short positions are entered when the price equals or goes below the lower Bollinger Band and the BandWidth is less than 120% of the lowest BandWidth.

Position Sizing

This expert advisor uses Percent Volatility position sizing. Verify the tick value, minimum and maximum lot sizes, size of lot increments, etc to confirm each position will not exceed your set risk percentage. Using the stop level, if the position is stopped out, the position size is calculated to only lose the amount risked through the Risk Percent variable. The calculation looks at how many dollars are at risk, how many pips are in the distance from the entry to the stop and the value of that distance.


The stop is set using multiples of the ATR. Basing the stop on the ATR allows the stop to be placed out of the normal price range and account for volatility. If you choose 2 times the 14 day ATR, the stop on long positions would happen if the price touches or goes below the entry price minus ( 2 * ATR ). The stop on short positions would occur if the price touches or goes above the entry price plus ( 2 * ATR ). The stop is set when the position is entered. The stop accounts for gaps in price and is not set as a pending order. A position is only stopped out if the price reaches or exceeds the stop level. If you use the pyramiding option, the stop will change to be in line with the latest entry price when a new position is added.


Positions are exited when the price goes to the opposite side of the moving average in the middle of the upper and lower Bollinger Bands. For long positions, the exit occurs when the price goes below the moving average. For short positions, the exit occurs when the price goes above the moving average. The exit is also only active when the BandWidth is outside of the entry threshold. By having this additional BandWidth criteria, it prevents exit when the price is moving in the close range of the squeeze when only the stop is needed if the price moves against the position.


Once you complete checkout through Paypal, you will receive an automated email with the download link. The email will go to the email address that is on file with Paypal - make sure Paypal has your current and correct email address. The download link will be active for 24 hours so please download as soon as you get the link. The expert advisor comes as the MQL4 code so you will have to save it in the correct folder, read through the notes in the code, and compile it. After compiling it, start testing and finding your profitable variables. Use the installation tips page to get the file saved and compiled so you can start testing today.