OPEN-SOURCE SCRIPT

Butterworth LPF Flip + AutoTune (PF)

62
Butterworth LPF Flip + AutoTune (PF)
This strategy trades price trend flips using two Butterworth low-pass filters (a FAST filter and a SLOW filter). A trade is taken when the FAST filter crosses the SLOW filter. Optionally, the script can auto-tune the filter lengths by simulating many Fast/Slow combinations and selecting the pair with the best Profit Factor (PF).
What the Script Does
- Computes two 2‑pole Butterworth low‑pass filters on price.
- Enters LONG when FAST crosses above SLOW.
- Enters SHORT when FAST crosses below SLOW.
- Optionally simulates many Fast/Slow length combinations internally.
- Chooses the Fast/Slow pair with the highest Profit Factor.
- Trades only the selected best pair.
Manual Mode (Default)
1. Leave Auto‑Tune OFF.
2. Set:
- FAST cutoff period (bars)
- SLOW cutoff period (bars)
3. The strategy will trade using only these values.

Use this mode for normal trading or live deployment.
Auto‑Tune Mode
1. Enable Auto‑Tune.
2. Define Fast and Slow ranges:
- FAST min / max / step
- SLOW min / max / step
3. The script simulates ALL Fast × Slow combinations bar‑by‑bar.
4. Each combination tracks:
- Gross Profit
- Gross Loss
- Closed trades
- Profit Factor (PF = GP / GL)
5. At the end of the chart, the best PF pair is selected and used for trading.
Interpreting the End Box
The status label at the end of the chart reports:
- Whether Auto‑Tune is enabled
- Number of candidate pairs tested
- Best FAST period
- Best SLOW period
- Profit Factor of the best pair
- Win Rate (wins ÷ closed trades)

If PF is near 1.0 or trades are very low, expand the range or length of the test.
Best Practices
- Use Auto‑Tune ONLY for research and optimization.
- After finding good parameters, disable Auto‑Tune and trade manually.
- Keep Fast < Slow (logical separation).
- Longer charts produce more reliable PF results.
- Avoid very small step sizes (performance + noise).
Known Limitations
- Pine Script runs bar‑by‑bar; tuning is approximate, not vectorized.
- Large grids increase execution time.
- Results are historical and NOT predictive.
- Not suitable for live auto‑optimization.
Summary
This script is best viewed as a *research tool first, strategy second*. Use it to discover stable Fast/Slow regimes, then lock them in for simple, repeatable trading.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。