OPEN-SOURCE SCRIPT
Persistence

# Persistence
## What it does
Measures **price change persistence**, defined as the percentage of bars within a lookback window that closed higher than the prior close. A high value means the instrument has been closing up frequently, which can indicate durable momentum. This mirrors Stockbee’s idea: *select stocks with high price change persistence*, and then combine **momentum plus persistence**.
## Can be used for scanning in PineScreener
## Calculation
* `isUp` is true when `close > close[1]`.
* `countUp` counts true instances over the last `len` bars.
* `pctUp = 100 * countUp / len`, bounded between 0 and 100.
* A 50% level is a natural baseline. Above 50% suggests more up closes than down closes in the window.
## Inputs
* **Lookback bars (`len`)**: default 252 for roughly one trading year on a daily chart. On weekly charts use something like 52, on monthly charts use 12.
## How to use
1. **Screen for persistence**
Sort a watchlist by the plotted value, higher is better. Many momentum traders start looking above 58 to 65 percent, then layer a trend filter.
2. **Combine with momentum**
Examples, pick tickers with:
* `pctUp > 60`, and price above a rising EMA50 or EMA100.
* `pctUp rising` and weekly ROC positive.
3. **Switch timeframe to change the horizon**
* Daily chart with `len = 252` approximates one year.
* Weekly chart with `len = 52` approximates one year.
* Monthly chart with `len = 12` approximates one year.
## TC2000 equivalence
Stockbee’s TC2000 expression:
```
CountTrue(c > c1, 252)
```
## Interpretation guide
* **70 to 90**: very strong persistence; often trend leaders, check for extensions and risk controls.
* **60 to 70**: constructive persistence; good hunting ground for swing setups that also pass momentum filters.
* **50**: neutral baseline; around random up vs down frequency.
* **Below 50**: persistent weakness; consider only for mean reversion or short strategies.
## Practical tips
* **Event effects**: ex-dividend gaps can reduce persistence on high yield names. Earnings gaps can swing the value sharply.
* **Survivorship bias**: when backtesting on curated lists, persistence can look cleaner than in live scans.
* **Liquidity**: thin names may show noisy persistence due to erratic prints.
## Reference to Stockbee
* “One way to select stocks for swing trading is to find those with high price change persistence.”
* “Persistence can be calculated on a daily, monthly, or weekly timeframe.”
* TC2000 function: `CountTrue(c > c1, 252)`
* Example noted in the tweet: CVNA had very high one-year price persistence at the time of that post.
* Takeaway: **look for momentum plus persistence**, not persistence alone.
## What it does
Measures **price change persistence**, defined as the percentage of bars within a lookback window that closed higher than the prior close. A high value means the instrument has been closing up frequently, which can indicate durable momentum. This mirrors Stockbee’s idea: *select stocks with high price change persistence*, and then combine **momentum plus persistence**.
## Can be used for scanning in PineScreener
## Calculation
* `isUp` is true when `close > close[1]`.
* `countUp` counts true instances over the last `len` bars.
* `pctUp = 100 * countUp / len`, bounded between 0 and 100.
* A 50% level is a natural baseline. Above 50% suggests more up closes than down closes in the window.
## Inputs
* **Lookback bars (`len`)**: default 252 for roughly one trading year on a daily chart. On weekly charts use something like 52, on monthly charts use 12.
## How to use
1. **Screen for persistence**
Sort a watchlist by the plotted value, higher is better. Many momentum traders start looking above 58 to 65 percent, then layer a trend filter.
2. **Combine with momentum**
Examples, pick tickers with:
* `pctUp > 60`, and price above a rising EMA50 or EMA100.
* `pctUp rising` and weekly ROC positive.
3. **Switch timeframe to change the horizon**
* Daily chart with `len = 252` approximates one year.
* Weekly chart with `len = 52` approximates one year.
* Monthly chart with `len = 12` approximates one year.
## TC2000 equivalence
Stockbee’s TC2000 expression:
```
CountTrue(c > c1, 252)
```
## Interpretation guide
* **70 to 90**: very strong persistence; often trend leaders, check for extensions and risk controls.
* **60 to 70**: constructive persistence; good hunting ground for swing setups that also pass momentum filters.
* **50**: neutral baseline; around random up vs down frequency.
* **Below 50**: persistent weakness; consider only for mean reversion or short strategies.
## Practical tips
* **Event effects**: ex-dividend gaps can reduce persistence on high yield names. Earnings gaps can swing the value sharply.
* **Survivorship bias**: when backtesting on curated lists, persistence can look cleaner than in live scans.
* **Liquidity**: thin names may show noisy persistence due to erratic prints.
## Reference to Stockbee
* “One way to select stocks for swing trading is to find those with high price change persistence.”
* “Persistence can be calculated on a daily, monthly, or weekly timeframe.”
* TC2000 function: `CountTrue(c > c1, 252)`
* Example noted in the tweet: CVNA had very high one-year price persistence at the time of that post.
* Takeaway: **look for momentum plus persistence**, not persistence alone.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。