Strategy · Pine Script v6 · On the chart

Breadth Dip Buying

by AlanGuo

A long-only strategy that combines a market breadth index, the percentage of stocks above their 50-day average, with a long moving average of 225 periods.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code67
Settings10inputs
LicenceNone stated
Last update7 months ago31 Mar 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

When price is above the average, it buys if breadth drops below 25. In bear mode, which is off by default, it buys after breadth rises back above 10. Entries need a slippage margin around the average, and it exits when price falls below the average. Backgrounds mark low breadth. There is no stop loss.

Details

Published by

AlanGuo on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Mean reversion, Moving averages

Markets

Indices, Stocks

Timeframes

H4 and above

Risk Notes

  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
50日宽度指标stringNDFIndfi_symbol
宽度下限(牛市)float25.0ndfi_lower_limit_above_ma
宽度下限(熊市)float10.0ndfi_lower_limit_below_ma
均线类型enumma_type.smaselected_ma_type
均线长度int225ma_length
滑点(%)float1slide_pct
牛抄booltruebuy_above_ma
熊右抄boolfalsebuy_under_ma
Datetimetimestamp("1 Feb 2018 00:00 +0800")start_date
Datetimetimestamp("31 Dec 2099 00:00 +0800")end_date
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

218 stars

The Mean Reversion Strategy Template calculates a baseline mean using SMA, EMA, or VWAP alongside upper and lower deviation bands based on standard deviation, ATR, or percentage offsets. It generates long and short entries when price touches, bounces from, or

Strategy v6 Mean reversionMoving averages
Updated 3 months ago · None stated GitHub repository of Mean Reversion Strategy Template

This strategy draws on the price chart and combines Stochastic RSI, the Money Flow Index, and an exponential moving average to open long or short trades. Longs use the lower oscillator thresholds and shorts use the upper ones, with direction limited to longs,

Strategy v5 Oscillators & momentumMoving averages Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 3 Indicator Strategy (StochRSI, MFI & EMA) With Safety Orders

Bollinger Bands Strategy

by cklose2000
105 stars

This strategy generates buy and sell signals based on Bollinger Band crossovers combined with a simple moving average trend filter. It enters a long position when price crosses above the lower band while trading above the SMA filter line, and enters a short po

Strategy v5 Volatility & bandsMoving averages
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Strategy
53 stars

This strategy identifies long entry opportunities based on short-term price pullbacks below a major trend filter. It enters long when three consecutive lower closes occur below the 200-period simple moving average, followed by the current bar closing back abov

Strategy v6 TrendMoving averages
Updated 2 months ago · MPL-2.0 GitHub repository of Ivan Scherman Pattern - TP/SL

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers