Type/to search

Dynamic Range Breakout Strategy

Cryptocurrency
Created: 2023-11-21 15:03:19
Last modified: 3 years ago
1
Follow
1779
Followers

img

Overview

This strategy is designed based on the Bollinger Bands indicator to create a dynamic breakout trading strategy. It combines the conditions of candle body filter and color filter to look for breakout entry opportunities around the Bollinger lower band. Exits are based on body filter. The strategy automatically manages position sizing and risk.

Strategy Logic

Indicator Calculation

First, calculate the base line and lower band of Bollinger Bands based on low price:

pine
src = low basis = sma(src, length) dev = mult * stdev(src, length) lower = basis - dev

Where src is the low price, length is the calculation period, basis is the moving average, dev is the standard deviation, and lower is the lower band.

mult is usually set to 2, meaning the lower band is one standard deviation away.

Filter Conditions

The strategy incorporates two filter conditions:

Candle Body Filter
Use the body size nbody and its mean abody to determine, only generate trading signal when nbody is greater than half of abody.

Color Filter
Do not long when candle closes positive (close > open). This avoids false breakout at the head of hbox.

Trading Signals

Generate long signal when below conditions meet:

pine
low < lower // price breaks lower band close < open or usecol == false // color filter nbody > abody / 2 or usebod == false // body filter

When body size exceeds half of the mean again, close position:

pine
close > open and nbody > abody / 2

Position Sizing

Strategy calculates trade size automatically for exponential growth of position:

pine
lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 : lot[1]

Risk Control

Add constraints on year, month and date to limit trading only in specific date range:

pine
when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59))

Advantages

Dynamic Trading Range

Bollinger lower band provides a dynamic support area to capture retracements after trends.

Dual Filter

Combination of candle body and color filters avoids false breakouts effectively.

Automatic Position Sizing

Position sizes up exponentially to 100% managing risk automatically.

Date Range

Setting a date range lowers risk associated with market volatility in specific periods.

Risks

Prolonged Drawdown

When strong uptrend, BB middle and upper bands may shift up quickly, causing prolonged drawdown.

Solutions

Combine with trend indicators, stop strategy when judged as bull market to avoid prolonged drawdown.

Failed Breakout

Breakout may fail with pullback and retest of lower band.

Solutions

Add stop loss below support level. Or add logic to detect failed retest for quick stop loss.

Enhancements

Add Stop Loss

Optimize stop loss below support based on backtest results.

Optimize Parameters

Fine tune body filter abody period, COLOR filter etc to find optimum.

Add Trend Filter

Stop strategy when judged as bull market. Reduce drawdown time.

Conclusion

This strategy combines BB support, body filter, color filter and breakout logic to capture high probability retracements. In practice, parameters can be optimized based on backtest, with stop loss and trend filter added to control risks for improved performance.

Source
Pine
/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Noro
//2018

//@version=2
Strategy parameters
Strategy parameters
Capital, %
BB Period
Use Body-Filter
Use Color-Filter
Show Arrows
From Year
To Year
From Month
To Month
From day
To day
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)