Search
Products
Community
Markets
News
Brokers
More
IN
Get started
Community
/
Ideas
/
//@version=5 strategy("Bollinger Retracement Strategy", overlay=
M
MANDIRI HERINDO ADIPERKASA TBK
//@version=5 strategy("Bollinger Retracement Strategy", overlay=
By ajiozora015
Follow
Follow
Jul 25, 2023
0
Jul 25, 2023
//
version
=5
strategy("Bollinger Retracement Strategy", overlay=true)
// Bollinger Band Settings
length = input(20, minval=1, title="Bollinger Length")
mult = input(2.0, minval=0.1, title="Bollinger Multiplier")
src = input(close, title="Source")
basis = sma(src, length)
dev = mult * stdev(src, length)
// Bollinger Bands
upperBB = basis + dev
lowerBB = basis - dev
// Buy Signal: Price crosses below the lower Bollinger Band
buySignal = crossover(close, lowerBB)
// Sell Signal: Price crosses above the upper Bollinger Band
sellSignal = crossunder(close, upperBB)
// Exit Signal: Price touches the middle Bollinger Band
exitSignal = close == basis
// Strategy logic
if (buySignal)
strategy.entry("Buy", strategy.long)
if (sellSignal)
strategy.close("Buy")
if (exitSignal)
strategy.close("Buy")
// Plotting Bollinger Bands for visual reference
plot(basis, color=color.blue, title="Middle Bollinger Band")
plot(upperBB, color=color.red, title="Upper Bollinger Band")
plot(lowerBB, color=color.green, title="Lower Bollinger Band")
Trend Analysis
ajiozora015
Follow
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the
Terms of Use
.