Volatility Breakout Expert Advisor and Squeeze Indicator .mq5 files for $299
Final sale of $50 for all tfmt5 Expert Advisor and Indicator .mq5 files
This Expert Advisor in .mq5 format has fully commented code to let you test, customize, and automate the Bollinger Band squeeze, also known as a volatility breakout, in MetaTrader 5. 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 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):
Note: The default input values are not optimized.
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
- MA_Periods - The number of bars to use to calculate the Bollinger Band's middle moving average line. Bollinger Bands commonly use a value of 20.
- Deviations - The number of standard deviations to use to calculate the upper and lower Bollinger Bands. A value of 2 is commonly used.
- Bandwidth_Bars - The number of bars/candlesticks back to use in calculating the lowest Bollinger BandWidth. Using this lowest level and the percent threshold in the next variable, entries will only occur when the prior bar's BandWidth is within your set range.
- Bandwidth_percent - Enter a percent value to create your acceptable threshold or range for entries. Example: If you want to have entries occur when the BandWidth is 120% or less of the lowest BandWidth of the last 100 bars, enter 20 to this variable. Putting numbers to the variable, if the lowest BandWidth is 1, entries would occur if the prior bar's BandWidth is less than 1.2.
- Risk Percent - The percent risked per position if stop is hit. Example: If you want 2% of your equity to be risked per position, enter 2 to this input.
- ATR Periods - Periods to use to calculate Average True Range. Example: If you want a 14 day ATR, enter 14. 10 day ATR, enter 10.
- Stop Range ATR - Multiples of ATR to use for calculating the stop. Example: If you want your stop to be set at 2* ATR from the price, enter 2 to this input.
- Max Units - Max number of positions to have at one time. Example: If you only want to pyramid to 5 positions, enter 5 to this input. If you do not want to pyramid positions, enter 1 to this input.
- ATR between Pyramids - Multiples of ATR to use for calculating when to add the next position through pyramiding. Example: Set this to 1.5 and the next pyramid position would be added when the price reaches your entry plus ( 1.5 * ATR ) for long positions or entry minus ( 1.5 * ATR ) for short positions.
- Slippage - Amount of allowable slippage when entering position.
- Reduction Percent - Enter an amount by which to reduce your equity for the position sizing calculation. Example: If you are in a drawdown period you can enter 20 to this input and the position size will be 20% less than without the reduction. The calculation would treat your equity as 80% of what it really is to lower your risk.
Markets
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.
Entry
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.
Stop
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.
Exit
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.
Delivery
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 MQL5 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.