LongTermTrend_V0421
ARCHIVEDhybridllm1) Added regime gates to restrict trading to uptrends and non-high volatility/bubble regimes to reduce drawdown and overfitting. 2) Simplified and strengthened entry: require price above sma_50, positive sma_50_slope, short-term momentum or breakout, and avoid extreme volatility (vol_pctile < 0.85). 3) Broadened exit to include MACD negative OR portfolio drawdown OR sharp 20d loss to stop bleeding faster. 4) Reduced base position to 0.6 and added two position rules: full size on confirmed breakout+positive MACD, reduced size when volatility percentile is high. These structural changes aim for more robust, lower-risk performance and better walk-forward stability.
Lineage
entry from LongTermTrend_V0323, exit from MACDMomentum_V0334
Strategy Logic (pseudocode)
# LongTermTrend_V0421 [hybrid]
require regime.trend in ['UPTREND']
require regime.volatility in ['LOW_VOLATILITY', 'MEDIUM_VOLATILITY']
require regime.bubble in ['NORMAL', 'EXPENSIVE']
if flat and (close > sma_50 and sma_50_slope > 0.0 and (ret_20d > 0.03 or breakout_20 > 0.0) and vol_pctile < 0.85):
position = 0.6
if long and (macd_hist < 0.0 or drawdown > 0.12 or ret_20d < -0.05):
position = 0.0 # exit to cashBacktest Metrics
| Metric | Train | Validation | Hidden Test | Full |
|---|---|---|---|---|
| CAGR | -0.1% | 11.8% | -1.7% | 1.9% |
| Total Return | -0.8% | 39.9% | -6.0% | 32.7% |
| Sharpe | 0.04 | 0.86 | -0.09 | 0.23 |
| Sortino | 0.02 | 0.64 | -0.04 | 0.14 |
| Calmar | -0.00 | 0.38 | -0.08 | 0.05 |
| Volatility | 9.9% | 14.2% | 11.5% | 11.3% |
| Max DD | -29.0% | -31.5% | -20.6% | -35.7% |
| Win Rate | 37.4% | 51.2% | 44.7% | 42.1% |
| Avg Win | 2.4% | 4.0% | 2.6% | 3.1% |
| Avg Loss | -1.5% | -2.2% | -2.3% | -1.8% |
| Payoff | 1.57 | 1.79 | 1.13 | 1.69 |
| Expectancy | -0.1% | 1.0% | -0.1% | 0.2% |
| Profit Factor | 0.94 | 1.88 | 0.92 | 1.23 |
| Trades | 99 | 41 | 38 | 178 |
| Avg Holding Days | 3.7 | 4.4 | 3.6 | 3.9 |
| Turnover | 15.0 | 16.4 | 12.3 | 14.6 |
| Exposure | 8.4% | 11.0% | 6.4% | 8.4% |
Growth of $100
Walk-Forward Years
| Year | CAGR | Sharpe | Max DD | Trades |
|---|---|---|---|---|
| 2016 | -4.0% | -0.70 | -8.1% | 8 |
| 2017 | 3.6% | 0.37 | -9.1% | 21 |
| 2018 | -12.2% | -1.89 | -12.1% | 7 |
| 2019 | 4.8% | 0.70 | -4.7% | 5 |
| 2020 | 44.1% | 2.54 | -4.8% | 11 |
| 2021 | 16.7% | 0.95 | -17.6% | 21 |
| 2022 | -17.0% | -2.44 | -17.0% | 8 |
A robust strategy performs acceptably in most years rather than spectacularly in one — look for consistency across regimes, not a single outlier year.
Regime Performance
| Period | Regime | Days | Ann. Return | Sharpe | Exposure |
|---|---|---|---|---|---|
| hidden test | DOWNTREND | 267 | 0.0% | 0.00 | 0% |
| hidden test | EXPENSIVE | 83 | 28.1% | 1.42 | 22% |
| hidden test | EXTREME | 48 | 0.0% | 0.00 | 0% |
| hidden test | HIGH VOLATILITY | 254 | -10.5% | -1.10 | 1% |
| hidden test | LOW VOLATILITY | 429 | 11.3% | 1.13 | 8% |
| hidden test | MEDIUM VOLATILITY | 248 | -12.5% | -0.83 | 9% |
| hidden test | NORMAL | 800 | -4.1% | -0.39 | 5% |
| hidden test | SIDEWAYS | 293 | -4.2% | -0.97 | 1% |
| hidden test | UPTREND | 371 | 0.8% | 0.05 | 16% |
| train | DOWNTREND | 518 | 0.0% | 0.00 | 0% |
| train | EXPENSIVE | 311 | 20.7% | 1.28 | 19% |
| train | EXTREME | 100 | 7.0% | 1.55 | 1% |
| train | HIGH VOLATILITY | 699 | 3.7% | 0.40 | 1% |
| train | LOW VOLATILITY | 745 | 5.0% | 0.47 | 17% |
| train | MEDIUM VOLATILITY | 568 | -9.7% | -1.02 | 7% |
| train | NORMAL | 1,601 | -4.0% | -0.47 | 7% |
| train | SIDEWAYS | 592 | -4.6% | -1.14 | 0% |
| train | UPTREND | 902 | 3.9% | 0.27 | 18% |
| validation | DOWNTREND | 125 | 0.0% | 0.00 | 0% |
| validation | EXPENSIVE | 138 | 59.1% | 2.83 | 25% |
| validation | EXTREME | 144 | 28.3% | 2.61 | 2% |
| validation | HIGH VOLATILITY | 258 | -7.1% | -1.00 | 0% |
| validation | LOW VOLATILITY | 183 | 4.4% | 0.39 | 19% |
| validation | MEDIUM VOLATILITY | 315 | 32.5% | 1.70 | 15% |
| validation | NORMAL | 474 | -6.4% | -0.51 | 10% |
| validation | SIDEWAYS | 206 | -11.2% | -1.91 | 1% |
| validation | UPTREND | 425 | 27.1% | 1.47 | 19% |
Trades (full period)
| Entry | Exit | Entry Px | Exit Px | Return | Days | |
|---|---|---|---|---|---|---|
| 2026-07-02 | 2026-07-06 | $393.45 | $419.77 | -4.61% | 2 | |
| 2026-05-29 | 2026-06-01 | $435.79 | $415.88 | -0.98% | 2 | |
| 2025-12-31 | 2026-01-02 | $449.72 | $438.07 | -0.74% | 2 | |
| 2025-12-08 | 2025-12-30 | $439.58 | $454.43 | 0.61% | 16 | |
| 2025-11-10 | 2025-11-11 | $445.23 | $439.62 | 2.07% | 2 | |
| 2025-11-06 | 2025-11-07 | $445.91 | $429.52 | -2.22% | 2 | |
| 2025-11-03 | 2025-11-05 | $468.37 | $462.07 | -1.70% | 3 | |
| 2025-10-29 | 2025-10-30 | $461.51 | $440.10 | 0.01% | 2 | |
| 2025-10-24 | 2025-10-27 | $433.72 | $452.42 | -2.16% | 2 | |
| 2025-10-22 | 2025-10-23 | $438.97 | $448.98 | -0.61% | 2 | |
| 2025-10-20 | 2025-10-21 | $447.43 | $442.60 | 0.99% | 2 | |
| 2025-10-13 | 2025-10-14 | $435.90 | $429.24 | 3.13% | 2 | |
| 2025-10-09 | 2025-10-10 | $435.54 | $413.49 | -0.55% | 2 | |
| 2025-10-07 | 2025-10-08 | $433.09 | $438.69 | -2.79% | 2 | |
| 2025-09-12 | 2025-10-06 | $395.94 | $453.25 | 9.73% | 17 | |
| 2025-09-04 | 2025-09-05 | $338.53 | $350.84 | 0.68% | 2 | |
| 2025-06-04 | 2025-06-05 | $332.05 | $284.70 | -2.25% | 2 | |
| 2025-05-22 | 2025-06-03 | $341.04 | $344.27 | 1.40% | 8 | |
| 2024-10-11 | 2024-10-14 | $217.80 | $219.16 | -5.39% | 2 | |
| 2024-10-09 | 2024-10-10 | $241.05 | $238.77 | -0.97% | 2 | |
| 2024-10-07 | 2024-10-08 | $240.83 | $244.50 | -2.34% | 2 | |
| 2024-10-03 | 2024-10-04 | $240.66 | $250.08 | -2.13% | 2 | |
| 2024-09-16 | 2024-09-20 | $226.78 | $238.25 | 3.45% | 5 | |
| 2024-09-06 | 2024-09-09 | $210.73 | $216.27 | -5.18% | 2 | |
| 2024-07-02 | 2024-07-12 | $231.26 | $248.23 | 8.84% | 8 | |
| 2024-01-03 | 2024-01-04 | $238.45 | $237.93 | -2.53% | 2 | |
| 2023-07-31 | 2023-08-01 | $267.43 | $261.07 | 0.10% | 2 | |
| 2023-07-27 | 2023-07-28 | $255.71 | $266.44 | -2.08% | 2 | |
| 2023-07-25 | 2023-07-26 | $265.28 | $264.35 | -0.96% | 2 | |
| 2023-07-20 | 2023-07-21 | $262.90 | $260.02 | -5.96% | 2 | |
| 2023-07-18 | 2023-07-19 | $293.34 | $291.26 | 0.49% | 2 | |
| 2023-07-14 | 2023-07-17 | $281.38 | $290.38 | 0.63% | 2 | |
| 2023-07-12 | 2023-07-13 | $271.99 | $277.90 | 0.37% | 2 | |
| 2023-07-10 | 2023-07-11 | $269.61 | $269.79 | -1.17% | 2 | |
| 2023-07-05 | 2023-07-07 | $282.48 | $274.43 | -0.82% | 3 | |
| 2023-06-30 | 2023-07-03 | $261.77 | $279.82 | 0.87% | 2 | |
| 2023-06-28 | 2023-06-29 | $256.24 | $257.50 | 1.33% | 2 | |
| 2023-06-02 | 2023-06-27 | $213.97 | $250.21 | 9.52% | 17 | |
| 2022-09-20 | 2022-09-23 | $308.73 | $275.33 | -4.12% | 4 | |
| 2022-09-12 | 2022-09-14 | $304.42 | $302.61 | -1.61% | 3 | |
| 2022-08-16 | 2022-08-19 | $306.56 | $296.67 | -1.37% | 4 | |
| 2022-08-05 | 2022-08-08 | $288.17 | $290.42 | -4.10% | 2 | |
| 2022-04-19 | 2022-04-20 | $342.72 | $325.73 | 1.30% | 2 | |
| 2022-04-14 | 2022-04-18 | $328.33 | $334.76 | -2.31% | 2 | |
| 2022-04-12 | 2022-04-13 | $328.98 | $340.79 | 0.56% | 2 | |
| 2022-04-05 | 2022-04-11 | $363.75 | $325.31 | -6.48% | 5 | |
| 2021-12-09 | 2021-12-10 | $334.60 | $339.01 | -3.78% | 2 | |
| 2021-11-26 | 2021-11-29 | $360.64 | $379.00 | -1.95% | 2 | |
| 2021-11-23 | 2021-11-24 | $369.68 | $372.00 | -2.60% | 2 | |
| 2021-10-12 | 2021-11-10 | $268.57 | $355.98 | 17.18% | 22 | |
| 2021-10-08 | 2021-10-11 | $261.83 | $263.98 | -0.73% | 2 | |
| 2021-09-28 | 2021-10-07 | $259.19 | $264.54 | -0.77% | 8 | |
| 2021-09-24 | 2021-09-27 | $258.13 | $263.79 | 1.53% | 2 | |
| 2021-09-22 | 2021-09-23 | $250.65 | $251.21 | 0.90% | 2 | |
| 2021-08-30 | 2021-09-21 | $243.64 | $246.46 | 1.46% | 16 | |
| 2021-08-26 | 2021-08-27 | $233.72 | $237.31 | -0.97% | 2 | |
| 2021-08-24 | 2021-08-25 | $236.16 | $237.07 | 0.07% | 2 | |
| 2021-08-19 | 2021-08-20 | $224.49 | $226.75 | -1.47% | 2 | |
| 2021-08-05 | 2021-08-17 | $238.21 | $221.90 | -2.18% | 9 | |
| 2021-02-10 | 2021-02-11 | $268.27 | $270.55 | -3.27% | 2 | |
| 2021-02-05 | 2021-02-08 | $284.08 | $287.81 | 0.04% | 2 | |
| 2021-02-03 | 2021-02-04 | $284.90 | $283.33 | -1.36% | 2 | |
| 2021-02-01 | 2021-02-02 | $279.94 | $290.93 | 3.38% | 2 | |
| 2021-01-28 | 2021-01-29 | $278.48 | $264.51 | -2.11% | 2 | |
| 2021-01-26 | 2021-01-27 | $294.36 | $288.05 | 0.04% | 2 | |
| 2021-01-12 | 2021-01-25 | $283.15 | $293.60 | 2.52% | 9 | |
| 2021-01-05 | 2021-01-11 | $245.04 | $270.40 | 11.92% | 5 | |
| 2020-12-31 | 2021-01-04 | $235.22 | $243.26 | 0.82% | 2 | |
| 2020-12-29 | 2020-12-30 | $222.00 | $231.59 | 0.09% | 2 | |
| 2020-12-24 | 2020-12-28 | $220.59 | $221.23 | 1.35% | 2 | |
| 2020-12-18 | 2020-12-23 | $231.67 | $215.33 | -1.45% | 4 | |
| 2020-12-10 | 2020-12-17 | $209.02 | $218.63 | 1.74% | 6 | |
| 2020-11-19 | 2020-12-08 | $166.42 | $216.63 | 18.20% | 13 | |
| 2020-10-26 | 2020-10-27 | $140.09 | $141.56 | -0.17% | 2 | |
| 2020-10-22 | 2020-10-23 | $141.93 | $140.21 | 0.33% | 2 | |
| 2020-10-13 | 2020-10-20 | $148.88 | $140.65 | -1.65% | 6 | |
| 2020-06-29 | 2020-06-30 | $67.29 | $71.99 | 2.98% | 2 | |
| 2020-06-25 | 2020-06-26 | $65.73 | $63.98 | 1.45% | 2 | |
| 2019-12-13 | 2020-01-22 | $23.89 | $37.97 | 28.95% | 26 | |
| 2019-12-04 | 2019-12-05 | $22.20 | $22.02 | -0.69% | 2 | |
| 2019-12-02 | 2019-12-03 | $22.32 | $22.41 | 0.78% | 2 | |
| 2019-11-27 | 2019-11-29 | $22.09 | $22.00 | 0.31% | 2 | |
| 2019-11-22 | 2019-11-25 | $22.20 | $22.42 | -3.80% | 2 | |
| 2019-10-21 | 2019-10-22 | $16.90 | $17.04 | -0.93% | 2 | |
| 2018-12-11 | 2018-12-18 | $24.45 | $22.47 | -2.84% | 6 | |
| 2018-12-07 | 2018-12-10 | $23.86 | $24.34 | -0.96% | 2 | |
| 2018-12-04 | 2018-12-06 | $23.98 | $24.20 | 0.08% | 2 | |
| 2018-11-29 | 2018-11-30 | $22.74 | $23.37 | -1.27% | 2 | |
| 2018-11-27 | 2018-11-28 | $22.93 | $23.19 | -0.48% | 2 | |
| 2018-02-08 | 2018-02-09 | $21.02 | $20.69 | -5.29% | 2 | |
| 2018-02-01 | 2018-02-05 | $23.28 | $22.21 | -1.91% | 3 | |
| 2017-10-09 | 2017-10-10 | $22.86 | $23.71 | -2.46% | 2 | |
| 2017-10-05 | 2017-10-06 | $23.69 | $23.79 | -0.07% | 2 | |
| 2017-09-18 | 2017-09-25 | $25.67 | $23.00 | -4.69% | 6 | |
| 2017-08-15 | 2017-08-18 | $24.16 | $23.16 | -2.08% | 4 | |
| 2017-08-04 | 2017-08-07 | $23.79 | $23.68 | 1.58% | 2 | |
| 2017-06-30 | 2017-07-03 | $24.11 | $23.51 | 0.02% | 2 | |
| 2017-06-05 | 2017-06-14 | $23.15 | $25.38 | 6.18% | 8 | |
| 2017-05-17 | 2017-05-18 | $20.41 | $20.87 | -2.18% | 2 | |
| 2017-05-12 | 2017-05-16 | $21.65 | $21.13 | -1.46% | 3 |