LongTermTrend_V1075
ARCHIVEDhybridllm1) Added a top-level trend and volatility filter: require sma_200_slope > 0 and vol_pctile < 0.7 to reduce trades in weak/upside-down regimes and extreme volatility. 2) Kept original entry logic but wrapped it with the new filters to emphasize structural uptrends. 3) Strengthened exits: changed single macd_hist exit to an OR of (macd_hist < 0) OR (price crossing below sma_50) OR (5d return < -6%) to provide clearer, faster stops and limit drawdowns. 4) Introduced regime gates to only trade in UPTREND and low/medium volatility, and avoid extreme bubble states. 5) Reduced base_position from 1.0 to 0.7 to lower leverage/exposure and improve robustness.
Lineage
changed sma_200_slope threshold -0.0024 -> -0.0003; changed cumret_252d threshold -0.1997 -> 0.2888
Strategy Logic (pseudocode)
# LongTermTrend_V1075 [hybrid]
require regime.trend in ['UPTREND']
require regime.volatility in ['LOW_VOLATILITY', 'MEDIUM_VOLATILITY']
require regime.bubble in ['NORMAL', 'EXPENSIVE']
if flat and (sma_200_slope > 0.0 and vol_pctile < 0.7 and ((((close > sma_200 and sma_200_slope > -0.0003) or ret_20d > 0.085) and ret_20d > 0.05 and cumret_252d > 0.2888 and dist_sma_50 > -0.0774) or ((macd_hist > 0.0 and close > sma_50) or ((breakout_50 == 1 and rel_volume > 2.0784) or ((macd_hist > 0.0 and close > sma_50) and sma_50 > sma_200))))):
position = 0.7
if long and (macd_hist < 0.0 or close < sma_50 or ret_5d < -0.06):
position = 0.0 # exit to cashBacktest Metrics
| Metric | Train | Validation | Hidden Test | Full |
|---|---|---|---|---|
| CAGR | 2.1% | 16.4% | -4.2% | 3.3% |
| Total Return | 17.9% | 57.6% | -14.6% | 61.9% |
| Sharpe | 0.25 | 1.02 | -0.43 | 0.34 |
| Sortino | 0.14 | 0.78 | -0.16 | 0.19 |
| Calmar | 0.14 | 0.55 | -0.22 | 0.08 |
| Volatility | 10.4% | 16.1% | 8.9% | 11.5% |
| Max DD | -14.7% | -29.6% | -18.9% | -39.9% |
| Win Rate | 38.9% | 55.3% | 25.0% | 42.6% |
| Avg Win | 4.1% | 4.5% | 3.9% | 4.6% |
| Avg Loss | -2.3% | -2.4% | -2.5% | -2.4% |
| Payoff | 1.80 | 1.85 | 1.55 | 1.95 |
| Expectancy | 0.2% | 1.4% | -0.9% | 0.6% |
| Profit Factor | 1.14 | 2.28 | 0.52 | 1.45 |
| Trades | 54 | 38 | 16 | 108 |
| Avg Holding Days | 4.7 | 4.5 | 4.8 | 4.7 |
| Turnover | 9.6 | 17.7 | 6.0 | 10.3 |
| Exposure | 7.3% | 12.3% | 4.5% | 7.6% |
Growth of $100
Walk-Forward Years
| Year | CAGR | Sharpe | Max DD | Trades |
|---|---|---|---|---|
| 2016 | 0.0% | 0.00 | 0.0% | 0 |
| 2017 | 2.8% | 0.27 | -9.5% | 16 |
| 2018 | -5.5% | -1.20 | -5.5% | 2 |
| 2019 | 11.5% | 1.66 | -2.6% | 0 |
| 2020 | 50.8% | 2.45 | -5.8% | 11 |
| 2021 | 20.7% | 1.04 | -18.6% | 19 |
| 2022 | -13.5% | -1.72 | -13.5% | 6 |
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 | 276 | 0.0% | 0.00 | 0% |
| hidden test | EXPENSIVE | 83 | 9.3% | 0.43 | 22% |
| hidden test | EXTREME | 48 | 0.0% | 0.00 | 0% |
| hidden test | HIGH VOLATILITY | 254 | -5.3% | -1.02 | 0% |
| hidden test | LOW VOLATILITY | 436 | 9.9% | 1.17 | 6% |
| hidden test | MEDIUM VOLATILITY | 250 | -26.3% | -2.22 | 6% |
| hidden test | NORMAL | 809 | -5.4% | -0.82 | 3% |
| hidden test | SIDEWAYS | 293 | -13.0% | -1.62 | 1% |
| hidden test | UPTREND | 371 | 0.5% | 0.04 | 10% |
| train | DOWNTREND | 518 | 0.0% | 0.00 | 0% |
| train | EXPENSIVE | 311 | 16.6% | 0.91 | 19% |
| train | EXTREME | 100 | 8.1% | 1.55 | 1% |
| train | HIGH VOLATILITY | 699 | 7.8% | 0.80 | 1% |
| train | LOW VOLATILITY | 745 | 7.7% | 0.71 | 14% |
| train | MEDIUM VOLATILITY | 568 | -10.5% | -1.00 | 6% |
| train | NORMAL | 1,601 | -0.5% | -0.06 | 5% |
| train | SIDEWAYS | 592 | -1.9% | -0.84 | 0% |
| train | UPTREND | 902 | 7.0% | 0.45 | 16% |
| validation | DOWNTREND | 125 | 0.0% | 0.00 | 0% |
| validation | EXPENSIVE | 138 | 70.3% | 2.95 | 28% |
| validation | EXTREME | 144 | 33.0% | 2.61 | 2% |
| validation | HIGH VOLATILITY | 258 | -8.3% | -1.00 | 0% |
| validation | LOW VOLATILITY | 183 | 13.5% | 1.22 | 20% |
| validation | MEDIUM VOLATILITY | 315 | 38.4% | 1.74 | 18% |
| validation | NORMAL | 474 | -4.3% | -0.30 | 11% |
| validation | SIDEWAYS | 206 | -6.0% | -1.16 | 0% |
| validation | UPTREND | 425 | 32.2% | 1.53 | 22% |
Trades (full period)
| Entry | Exit | Entry Px | Exit Px | Return | Days | |
|---|---|---|---|---|---|---|
| 2026-07-01 | 2026-07-06 | $425.30 | $419.77 | -4.63% | 3 | |
| 2026-05-29 | 2026-06-01 | $435.79 | $415.88 | -1.14% | 2 | |
| 2025-12-04 | 2025-12-30 | $454.53 | $454.43 | 1.98% | 18 | |
| 2025-11-06 | 2025-11-07 | $445.91 | $429.52 | -2.59% | 2 | |
| 2025-11-03 | 2025-11-05 | $468.37 | $462.07 | -1.99% | 3 | |
| 2025-10-24 | 2025-10-27 | $433.72 | $452.42 | -2.52% | 2 | |
| 2025-10-14 | 2025-10-15 | $429.24 | $435.15 | -1.21% | 2 | |
| 2025-10-09 | 2025-10-10 | $435.54 | $413.49 | -0.64% | 2 | |
| 2025-10-07 | 2025-10-08 | $433.09 | $438.69 | -3.25% | 2 | |
| 2025-09-12 | 2025-10-06 | $395.94 | $453.25 | 11.37% | 17 | |
| 2025-09-04 | 2025-09-05 | $338.53 | $350.84 | 0.79% | 2 | |
| 2025-07-29 | 2025-07-30 | $321.20 | $319.04 | -1.08% | 2 | |
| 2025-07-21 | 2025-07-25 | $328.49 | $316.06 | -5.29% | 5 | |
| 2025-06-04 | 2025-06-05 | $332.05 | $284.70 | -2.62% | 2 | |
| 2025-05-22 | 2025-06-03 | $341.04 | $344.27 | 1.61% | 8 | |
| 2023-08-30 | 2023-09-05 | $256.90 | $256.49 | -3.44% | 4 | |
| 2022-08-16 | 2022-08-19 | $306.56 | $296.67 | -1.60% | 4 | |
| 2022-08-05 | 2022-08-08 | $288.17 | $290.42 | -4.78% | 2 | |
| 2022-04-20 | 2022-04-21 | $325.73 | $336.26 | -3.61% | 2 | |
| 2022-04-18 | 2022-04-19 | $334.76 | $342.72 | 1.23% | 2 | |
| 2022-04-13 | 2022-04-14 | $340.79 | $328.33 | 2.37% | 2 | |
| 2022-04-05 | 2022-04-11 | $363.75 | $325.31 | -7.53% | 5 | |
| 2021-12-28 | 2022-01-03 | $362.82 | $399.93 | -2.52% | 5 | |
| 2021-11-26 | 2021-11-29 | $360.64 | $379.00 | -2.28% | 2 | |
| 2021-11-23 | 2021-11-24 | $369.68 | $372.00 | -3.03% | 2 | |
| 2021-10-12 | 2021-11-10 | $268.57 | $355.98 | 20.11% | 22 | |
| 2021-10-08 | 2021-10-11 | $261.83 | $263.98 | -0.86% | 2 | |
| 2021-09-27 | 2021-10-07 | $263.79 | $264.54 | 0.62% | 9 | |
| 2021-09-23 | 2021-09-24 | $251.21 | $258.13 | 0.02% | 2 | |
| 2021-08-31 | 2021-09-21 | $245.24 | $246.46 | -0.18% | 15 | |
| 2021-08-26 | 2021-08-27 | $233.72 | $237.31 | -1.13% | 2 | |
| 2021-08-24 | 2021-08-25 | $236.16 | $237.07 | 0.08% | 2 | |
| 2021-08-19 | 2021-08-20 | $224.49 | $226.75 | -1.72% | 2 | |
| 2021-08-05 | 2021-08-17 | $238.21 | $221.90 | -2.55% | 9 | |
| 2021-02-05 | 2021-02-08 | $284.08 | $287.81 | 0.04% | 2 | |
| 2021-02-03 | 2021-02-04 | $284.90 | $283.33 | -1.59% | 2 | |
| 2021-02-01 | 2021-02-02 | $279.94 | $290.93 | 3.94% | 2 | |
| 2021-01-28 | 2021-01-29 | $278.48 | $264.51 | -2.47% | 2 | |
| 2021-01-26 | 2021-01-27 | $294.36 | $288.05 | 0.04% | 2 | |
| 2021-01-20 | 2021-01-25 | $283.48 | $293.60 | 0.03% | 4 | |
| 2021-01-12 | 2021-01-19 | $283.15 | $281.52 | 1.18% | 5 | |
| 2021-01-05 | 2021-01-11 | $245.04 | $270.40 | 13.99% | 5 | |
| 2020-12-31 | 2021-01-04 | $235.22 | $243.26 | 0.96% | 2 | |
| 2020-12-29 | 2020-12-30 | $222.00 | $231.59 | 0.10% | 2 | |
| 2020-12-24 | 2020-12-28 | $220.59 | $221.23 | 1.57% | 2 | |
| 2020-12-18 | 2020-12-23 | $231.67 | $215.33 | -1.72% | 4 | |
| 2020-12-10 | 2020-12-17 | $209.02 | $218.63 | 2.02% | 6 | |
| 2020-11-19 | 2020-12-08 | $166.42 | $216.63 | 21.45% | 13 | |
| 2020-11-09 | 2020-11-10 | $140.42 | $136.79 | -1.55% | 2 | |
| 2020-10-22 | 2020-10-23 | $141.93 | $140.21 | 0.38% | 2 | |
| 2020-10-13 | 2020-10-20 | $148.88 | $140.65 | -1.93% | 6 | |
| 2020-06-29 | 2020-06-30 | $67.29 | $71.99 | 3.48% | 2 | |
| 2020-06-25 | 2020-06-26 | $65.73 | $63.98 | 1.69% | 2 | |
| 2019-12-16 | 2020-01-22 | $25.43 | $37.97 | 34.73% | 25 | |
| 2018-12-11 | 2018-12-18 | $24.45 | $22.47 | -3.32% | 6 | |
| 2018-02-01 | 2018-02-05 | $23.28 | $22.21 | -2.23% | 3 | |
| 2017-10-18 | 2017-10-20 | $23.98 | $23.01 | -0.91% | 3 | |
| 2017-10-12 | 2017-10-17 | $23.71 | $23.72 | -0.93% | 4 | |
| 2017-09-18 | 2017-09-25 | $25.67 | $23.00 | -5.46% | 6 | |
| 2017-08-15 | 2017-08-18 | $24.16 | $23.16 | -2.42% | 4 | |
| 2017-08-04 | 2017-08-07 | $23.79 | $23.68 | 1.84% | 2 | |
| 2017-06-30 | 2017-07-03 | $24.11 | $23.51 | 0.03% | 2 | |
| 2017-06-05 | 2017-06-14 | $23.15 | $25.38 | 7.23% | 8 | |
| 2017-05-17 | 2017-05-18 | $20.41 | $20.87 | -2.55% | 2 | |
| 2017-05-12 | 2017-05-16 | $21.65 | $21.13 | -1.70% | 3 | |
| 2017-05-02 | 2017-05-04 | $21.26 | $19.70 | -2.70% | 3 | |
| 2017-04-20 | 2017-04-21 | $20.17 | $20.37 | -0.83% | 2 | |
| 2017-03-24 | 2017-04-04 | $17.54 | $20.25 | 11.66% | 8 | |
| 2017-03-20 | 2017-03-22 | $17.46 | $17.00 | -3.03% | 3 | |
| 2017-02-23 | 2017-02-24 | $17.07 | $17.13 | -4.62% | 2 | |
| 2017-02-10 | 2017-02-22 | $17.95 | $18.23 | 2.02% | 8 | |
| 2017-01-05 | 2017-02-02 | $15.12 | $16.77 | 6.65% | 20 | |
| 2015-07-21 | 2015-07-22 | $17.78 | $17.86 | -3.98% | 2 | |
| 2015-05-13 | 2015-05-22 | $16.21 | $16.52 | 0.12% | 8 | |
| 2014-10-08 | 2014-10-10 | $17.29 | $15.79 | -0.83% | 3 | |
| 2014-09-15 | 2014-09-16 | $16.92 | $17.38 | -6.49% | 2 | |
| 2014-09-02 | 2014-09-12 | $18.94 | $18.61 | 2.65% | 9 | |
| 2014-08-28 | 2014-08-29 | $17.59 | $17.98 | 0.02% | 2 | |
| 2014-08-26 | 2014-08-27 | $17.45 | $17.55 | -0.36% | 2 | |
| 2014-07-31 | 2014-08-25 | $14.89 | $17.50 | 8.31% | 18 | |
| 2014-07-14 | 2014-07-15 | $15.11 | $14.64 | 2.61% | 2 | |
| 2014-07-10 | 2014-07-11 | $14.63 | $14.54 | -1.27% | 2 | |
| 2014-07-08 | 2014-07-09 | $14.60 | $14.87 | -1.27% | 2 | |
| 2014-06-23 | 2014-07-07 | $15.81 | $14.84 | -0.20% | 10 | |
| 2014-03-24 | 2014-03-25 | $14.68 | $14.70 | -2.80% | 2 | |
| 2014-03-20 | 2014-03-21 | $15.66 | $15.26 | -0.42% | 2 | |
| 2014-02-13 | 2014-02-26 | $13.31 | $16.87 | 18.38% | 9 | |
| 2013-10-16 | 2013-10-17 | $12.24 | $12.19 | -0.28% | 2 | |
| 2013-10-14 | 2013-10-15 | $11.98 | $12.26 | 0.26% | 2 | |
| 2013-10-09 | 2013-10-10 | $11.25 | $11.53 | -2.52% | 2 | |
| 2013-10-07 | 2013-10-08 | $12.20 | $11.65 | 0.67% | 2 | |
| 2013-09-23 | 2013-10-04 | $12.07 | $12.07 | -3.94% | 10 | |
| 2013-09-19 | 2013-09-20 | $11.86 | $12.23 | 4.78% | 2 | |
| 2013-09-17 | 2013-09-18 | $11.08 | $11.08 | -0.29% | 2 | |
| 2013-09-13 | 2013-09-16 | $11.04 | $11.11 | 0.12% | 2 | |
| 2013-09-11 | 2013-09-12 | $10.90 | $11.00 | -1.34% | 2 | |
| 2013-09-09 | 2013-09-10 | $10.71 | $11.09 | -2.77% | 2 | |
| 2013-03-27 | 2013-04-02 | $2.54 | $2.96 | 11.07% | 4 | |
| 2013-03-08 | 2013-03-18 | $2.56 | $2.34 | -5.53% | 7 | |
| 2013-02-04 | 2013-02-14 | $2.52 | $2.55 | 0.15% | 9 |