Butterworth LPF Flip + AutoTune (PF) — Strategy by AJSwogger
By AJSwogger
Performance Metrics
- Author: AJSwogger
- Symbol: NASDAQ:SOFI
- Timeframe: 1 minute
- Net P&L: +6.14 USD (+0.01%)
- Win Rate: 45.6%
- Profit Factor: 1.333
- Max Drawdown: 8.70 USD (0.01%)
- Total Trades: 46
Description
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 Mode1. Enable Auto‑Tune.2. Define Fast and Slow ranges: - FAST min / max / step - SLOW min / max / step3. 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 BoxThe 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.SummaryThis 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.