To create a PineScript script that is sensitive to Bollinger Bands and enters positions when the price touches the upper or lower bands, we'll use TradingView's PineScript language. The script will:
Here's the artifact containing the PineScript code:
Inputs:
length: Length of the moving average used in Bollinger Bands (default is 20).mult: Standard deviation multiplier (default is 2.0).Bollinger Bands Calculation:
mid: Simple Moving Average (SMA) of the closing price.dev: Standard deviation multiplied by the user-defined multiplier.upper and lower: Upper and lower bands calculated as mid ± dev.Price Touch Detection:
ta.crossover(close, upper): Detects when the price crosses above the upper band.ta.crossunder(close, lower): Detects when the price crosses below the lower band.Strategy Entries:
Optional Exit Logic:
Visualization:
length and mult) as needed.This script is sensitive to price movements near the Bollinger Bands and generates entries when the price touches the upper or lower bands. Adjust the parameters and exit logic as per your trading strategy.