Bollinger 5-Minute Breakout Intraday For ThinkOrSwim

QUIKTDR1

Active member
VIP
Author states:
The strategy is named "Bollinger 5-Minute Breakout Intraday Trading Strategy," which is a short-term trading strategy based on the Bollinger Bands indicator and designed for 5-minute timeframe intraday trading. The strategy utilizes Bollinger Bands to capture short-term breakout opportunities in the market, entering long positions when the price breaks above the upper band and closing positions when it breaks below the lower band. Additionally, the strategy strictly adheres to intraday trading principles, closing all positions before 3 PM each trading day to avoid overnight holding risks.

The main ideas of this strategy are as follows:

  1. Calculate the Bollinger Bands indicator, with the upper band being the 100-period simple moving average plus 3 standard deviations and the lower band being the 100-period simple moving average minus 1 standard deviation.
  2. When the closing price breaks above the upper band, enter a long position.
  3. When the closing price breaks below the lower band or reaches 3 PM, close the position.
  4. Mark the entry points with green triangles and the exit points with red triangles on the chart, and highlight them with light green and light red backgrounds.
The principle of this strategy is to use Bollinger Bands to capture short-term trends and fluctuations in the market. Bollinger Bands consist of three lines: the middle band, upper band, and lower band. The middle band is the moving average of the price, while the upper and lower bands are a certain number of standard deviations above and below the middle band, respectively. When the price breaks above the upper band, it indicates that an upward trend is forming and it is a good time to buy; when the price breaks below the lower band, it suggests that the upward trend may be ending and the position should be closed. At the same time, this strategy strictly controls risk by closing all positions before 3 PM each trading day to avoid potentially huge losses from overnight holdings.

The advantages of this strategy are:

  1. Suitable for short-term trading: This strategy is based on a 5-minute timeframe and is designed for short-term traders to quickly capture short-term opportunities in the market.
  2. Strict risk control: The strategy closes all positions before 3 PM each trading day, avoiding the risks of overnight holdings.
  3. Simple and easy to use: The strategy's logic is clear and straightforward, only requiring opening and closing positions based on breakouts of the Bollinger Bands indicator.
  4. Widely applicable markets: The strategy can be applied to various markets, such as stocks, futures, and foreign exchange.
The risks of this strategy include:

  1. Frequent trading: Based on a 5-minute timeframe, this strategy has a high trading frequency, which may generate more commission and slippage costs.
  2. Severe market fluctuations: In cases of severe market fluctuations, this strategy may generate more false signals, leading to losses.
  3. Unclear trends: When market trends are unclear, this strategy may generate more random trades, resulting in losses.
To address the risks of this strategy, the following optimization directions can be considered:

  1. Parameter optimization: Optimize the period and standard deviation multiplier of the Bollinger Bands to improve the strategy's stability and accuracy.
  2. Introduce other indicators: Introduce other technical indicators, such as RSI and MACD, to filter false signals and enhance the strategy's accuracy.
  3. Introduce stop-loss and take-profit: Set reasonable stop-loss and take-profit points to control the risk of individual trades and improve the strategy's risk-reward ratio.
  4. Combine with fundamental analysis: Combine relevant market fundamentals, such as economic data and policy changes, to select appropriate trading timing and improve the strategy's accuracy.
In summary, the "Bollinger 5-Minute Breakout Intraday Trading Strategy" is a simple, easy-to-use strategy suitable for short-term trading. It utilizes the Bollinger Bands indicator to capture short-term trends and fluctuations in the market while strictly controlling risk by avoiding overnight holdings. Although this strategy also has some risks, such as frequent trading and false signals, methods like optimizing parameters, introducing other indicators, setting stop-loss and take-profit, and combining fundamental analysis can further improve the strategy's stability and profitability. Overall, for investors seeking short-term trading opportunities, this strategy is worth trying.
dDoTCFM.png


The original address: Bollinger 5-Minute Breakout Intraday Trading Strategy (fmz.com)
https://medium.com/tag/trading-stra...------------trading_strategy-----------------
The ThinkOrSwim code can be found in the next post.
 
Last edited by a moderator:
The original address: Bollinger 5-Minute Breakout Intraday Trading Strategy (fmz.com)
https://medium.com/tag/trading-stra...------------trading_strategy-----------------

Strategy source code
/*backtest
start: 2023-03-22 00:00:00
end: 2024-03-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Bollinger Breakout Strategy 5m", shorttitle="BB Strategy 5m", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, margin_long=100)

// Define the strategy parameters
length = 100
multUpper = 3.0
multLower = 1.0
src = close

// Calculate Bollinger Bands
basis = ta.sma(src, length)
upperDev = multUpper * ta.stdev(src, length)
lowerDev = multLower * ta.stdev(src, length)
upperBand = basis + upperDev
lowerBand = basis - lowerDev

// Plot Bollinger Bands
plot(basis, "Basis", color=color.blue)
plot(upperBand, "Upper Band", color=color.green)
plot(lowerBand, "Lower Band", color=color.red)

// Entry and exit conditions
enterLong = ta.crossover(src, upperBand)
exitLong = ta.crossunder(src, lowerBand)

// Visual signals for entries and exits
bgcolor(enterLong ? color.new(color.green, 90) : na, title="Entry Background")
bgcolor(exitLong ? color.new(color.red, 90) : na, title="Exit Background")
plotshape(enterLong, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Enter Long")
plotshape(exitLong, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Exit Long")

// Adjusting for timezone - Ensure the time is converted to the exchange's timezone
session_close_hour = 15 // 3 PM in EST, adjust if your trading platform uses a different timezone
is_time_to_exit = (hour >= session_close_hour and minute > 0) or (hour > session_close_hour)

// Trading logic
if (enterLong)
strategy.entry("Long", strategy.long)

if (exitLong or is_time_to_exit)
strategy.close("Long")

// Note: Adjust 'session_close_hour' to match your exchange's closing hour if it differs from EST.

samer800 Could you please convert TY

samer800 Could you give this a try to convert?
check the below. I added Long and Short bubbles

CSS:
#// Indicator for TOS
#strategy("Bollinger Breakout Strategy 5m", shorttitle="BB Strategy 5m", overlay=true, defa
# Converted bySam4Cok@Samer800    - 08/2024 - Request from www.useThinkScript.com member
#// Define the strategy parameters
input tradingDirections = {Default "Long & Short", "Long Only", "Short Only"};
input movAvgType = AverageType.SIMPLE;
input src = close;
input length = 100;
input UpperMultiplier = 3.0;
input LowerMultiplier = 1.0;

def na = Double.NaN;
def long = tradingDirections!=tradingDirections."Short Only";
def short = tradingDirections!=tradingDirections."Long Only";

#// Calculate Bollinger Bands
def basis = MovingAverage(movAvgType, src, length);
def upperDev = UpperMultiplier * stdev(src, length);
def lowerDev = LowerMultiplier * stdev(src, length);
def upperBand = basis + upperDev;
def lowerBand = basis - lowerDev;

#// Plot Bollinger Bands
plot basisLine = basis; #, "Basis", color=color.blue)
plot Upper = upperBand; #, "Upper Band", color=color.green)
plot Lower = lowerBand; #, "Lower Band", color=color.red)
basisLine.SetDefaultColor(Color.GRAY);
upper.SetDefaultColor(Color.DARK_GREEN);
lower.SetDefaultColor(Color.DARK_RED);

#// Entry and exit conditions
def changeDay = GetDay()!=GetDay()[1];
def enterLong = long and (src Crosses Above  upperBand);
def enterShort = short and (src Crosses Below lowerBand);
def exitLong  = changeDay or (src Crosses Below basis);
def exitShort = changeDay or (src Crosses Above basis);
def inTradeL = if enterLong then yes else if exitLong then no else inTradeL[1];
def inTradeS = if enterShort then yes else if exitShort then no else inTradeS[1];

def exitLCond = inTradeL[1] and exitLong;
def exitSCond = inTradeS[1] and exitShort;
def enterLCond = (!inTradeL[1] or exitLCond) and enterLong;
def enterSCond = (!inTradeS[1] or exitSCond) and enterShort;

AddChartBubble(enterLCond, low, "L", Color.GREEN, no);
AddChartBubble(exitLCond[-1], high, "Exit L", Color.DARK_GREEN);

AddChartBubble(enterSCond, high, "S", Color.RED);
AddChartBubble(exitSCond[-1], low, "Exit S", Color.DARK_RED, no);

#-- END of CODE
 
check the below. I added Long and Short bubbles

CSS:
#// Indicator for TOS
#strategy("Bollinger Breakout Strategy 5m", shorttitle="BB Strategy 5m", overlay=true, defa
# Converted bySam4Cok@Samer800    - 08/2024 - Request from www.useThinkScript.com member
#// Define the strategy parameters
input tradingDirections = {Default "Long & Short", "Long Only", "Short Only"};
input movAvgType = AverageType.SIMPLE;
input src = close;
input length = 100;
input UpperMultiplier = 3.0;
input LowerMultiplier = 1.0;

def na = Double.NaN;
def long = tradingDirections!=tradingDirections."Short Only";
def short = tradingDirections!=tradingDirections."Long Only";

#// Calculate Bollinger Bands
def basis = MovingAverage(movAvgType, src, length);
def upperDev = UpperMultiplier * stdev(src, length);
def lowerDev = LowerMultiplier * stdev(src, length);
def upperBand = basis + upperDev;
def lowerBand = basis - lowerDev;

#// Plot Bollinger Bands
plot basisLine = basis; #, "Basis", color=color.blue)
plot Upper = upperBand; #, "Upper Band", color=color.green)
plot Lower = lowerBand; #, "Lower Band", color=color.red)
basisLine.SetDefaultColor(Color.GRAY);
upper.SetDefaultColor(Color.DARK_GREEN);
lower.SetDefaultColor(Color.DARK_RED);

#// Entry and exit conditions
def changeDay = GetDay()!=GetDay()[1];
def enterLong = long and (src Crosses Above  upperBand);
def enterShort = short and (src Crosses Below lowerBand);
def exitLong  = changeDay or (src Crosses Below basis);
def exitShort = changeDay or (src Crosses Above basis);
def inTradeL = if enterLong then yes else if exitLong then no else inTradeL[1];
def inTradeS = if enterShort then yes else if exitShort then no else inTradeS[1];

def exitLCond = inTradeL[1] and exitLong;
def exitSCond = inTradeS[1] and exitShort;
def enterLCond = (!inTradeL[1] or exitLCond) and enterLong;
def enterSCond = (!inTradeS[1] or exitSCond) and enterShort;

AddChartBubble(enterLCond, low, "L", Color.GREEN, no);
AddChartBubble(exitLCond[-1], high, "Exit L", Color.DARK_GREEN);

AddChartBubble(enterSCond, high, "S", Color.RED);
AddChartBubble(exitSCond[-1], low, "Exit S", Color.DARK_RED, no);

#-- END of CODE
TY Great work as usual
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
327 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top