INVITE-ONLY SCRIPT

BB scalping

54
1. Overview
The BB Scalping Strategy is a systematic trading approach designed for TradingView, implemented in Pine Script™ v5. It combines Bollinger Bands®, a fast-moving average, and the Awesome Oscillator to identify short-term (scalping) entry and exit opportunities in trending markets. The strategy includes configurable backtesting periods, trading time windows, and integrated risk management via stop-loss orders.

2. Core Trading Logic
The strategy generates signals based on the confluence of three technical indicators:

Bollinger Bands (BB): The core indicator. A crossover of a fast EMA above or below the BB middle line (basis) serves as the primary entry trigger.

Awesome Oscillator (AO): Used as a momentum filter. A buy signal requires bullish momentum (AO rising and above its midline), while a sell signal requires bearish momentum (AO falling and below its midline).

Fast Exponential Moving Average (EMA): A short-period EMA (default: 3) that quickly reacts to price changes, providing timely crossover signals with the BB basis.

3. Key Features

Dual Entry Signals:

Long Entry: Triggered when the Fast EMA crosses above the BB basis, price is above the basis, and the Awesome Oscillator confirms bullish momentum.

Short Entry: Triggered when the Fast EMA crosses below the BB basis, price is below the basis, and the Awesome Oscillator confirms bearish momentum.

Advanced Filtering Options:

BB Filter: When enabled, long entries are only valid if the price is below the BB upper band, and short entries are only valid if the price is above the BB lower band.

Squeeze Filter: When enabled, entries are only permitted during a "squeeze" (low volatility period), identified when the BB width is below a user-defined threshold percentage of its historical average.

Precise Backtesting Control:

Date Range Filter: Allows users to define a specific start and end date for historical backtesting.

Trading Time Window: Restricts trading activity to specific hours of the day (in 24h format), allowing simulation of a specific session (e.g., a market open session).

Integrated Risk Management:

Stop-Loss Orders: A fixed percentage-based stop-loss is automatically calculated and set for every trade upon entry (e.g., 1%). This is a critical feature for managing risk in a scalping strategy.

4. Chart Visualization
The script provides clear visual cues on the chart:

Plots the Bollinger Bands and the Fast EMA.

Colors the BB channel to indicate a "squeeze" (blue) or high-volatility (white) state.

Displays up/down arrow markers directly on the chart at the exact point where buy and sell signals are generated.

5. Usage Notes

Optimal Environment: This strategy is designed for trending markets and may generate false signals during sideways or choppy conditions, especially if the squeeze filter is disabled.

Parameter Tuning: Users are encouraged to optimize parameters (like BB length, multiplier, EMA length, and stop-loss percentage) for different instruments and timeframes.

Backtesting: Always conduct thorough backtesting over a significant period of data and different market conditions before deploying any strategy with real capital.

Disclaimer: This strategy is provided for educational and research purposes only. Past performance is not indicative of future results. Trading financial instruments carries a high level of risk and may not be suitable for all investors. 1. 策略概述
BB剥头皮策略是一款基于TradingView平台、使用Pine Script™ v5语言编写的自动化交易策略。该策略综合运用了布林带 (Bollinger Bands®)、快速指数移动平均线 (EMA) 和动量震荡指标 (Awesome Oscillator) 来捕捉市场短期的趋势性机会,旨在通过频繁的小额盈利(剥头皮)实现收益。策略内置了可定制的回测时间范围、交易时间窗口以及基于百分比的止损来管理风险。

2. 核心交易逻辑
策略的信号生成依赖于三个技术指标的共振:

布林带 (BB): 核心指标。当快速EMA上穿或下穿布林带中线(基准线)时,构成主要入场触发条件。

动量震荡指标 (AO): 用作动量过滤器。买入信号需要看涨动量(AO为正且在上升),卖出信号需要看跌动量(AO为负且在下降)。

快速指数移动平均线 (EMA): 一条短周期EMA(默认3),对价格变化反应灵敏,提供与布林带中线的及时交叉信号。

3. 策略功能特点

多空双向信号:

多头入场(买入): 当快速EMA上穿布林带中线、价格位于中线上方,且AO指标确认看涨动量时触发。

空头入场(卖出): 当快速EMA下穿布林带中线、价格位于中线下方,且AO指标确认看跌动量时触发。

高级过滤选项:

布林带过滤: 启用后,多头信号需价格低于布林带上轨,空头信号需价格高于布林带下轨,以提高信号质量。

收窄过滤 (Squeeze Filter): 启用后,仅在布林带“收窄”(低波动期)时才允许交易,此时布林带宽度低于其历史平均宽度的一定阈值(百分比),预示着潜在的趋势突破机会。

灵活的回测设置:

日期范围控制: 用户可以精确设置策略回测的起止年月日,用于检验特定历史时期的表现。

交易时间窗口: 可将交易活动限制在每天的特定时段(24小时制),例如只在北京时间上午或某个特定市场开盘时段进行交易,模拟实盘操作习惯。

严格的风险管理:

百分比止损: 每次入场后,策略会根据用户设定的百分比(例如1%)自动计算并设置止损单,这是控制剥头皮交易风险的关键功能。

4. 图表可视化
策略在图表上提供了清晰的视觉信号:

绘制布林带和快速EMA线。

根据布林带是否收窄,对通道进行不同颜色的填充(蓝色表示收窄,白色表示扩张)。

在生成买入和卖出信号的位置直接显示向上箭头和向下箭头标记,直观清晰。

5. 使用说明与风险提示

适用环境: 本策略在趋势性市场中表现更佳,在横盘震荡市中可能会产生连续假信号,尤其是在关闭收窄过滤功能时。

参数优化: 建议用户根据不同的交易品种和时间框架(如5分钟、15分钟图)对策略参数(如布林带周期、乘数、EMA长度、止损百分比)进行测试和优化。

风险警告: 该策略仅用于教育和研究目的。所有回测结果均代表历史表现,并不保证未来收益。金融市场交易存在高风险,可能导致本金损失,未必适合所有投资者。请在完全了解风险后,再谨慎使用。

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.