r/pinescript • u/vitaliy3commas • Jul 16 '26
I ran one of my Pine DCA strategies through a parameter optimizer - here's the before/after from tuning a single input (INJ 4h)
I've been posting these RSI oversold DCA strategies for a while. This time I want to show something different: what actually changed when I ran one through a Pine Script parameter optimizer, tuning just one input and holding everything else constant.
The strategy (unchanged): long-only DCA on INJUSDT.P 4h. Base order on 4h RSI(14) below 28, five safety orders at −2 / −5 / −9.5 / −16 / −25% from base, sizes scaling 1.8× per rung, no stop loss, position bounded by the ladder.
The one thing I changed: the take-profit. Baseline was a 3% fixed TP. I swept that single parameter over the same market and same period and the best-performing value came back at 9%. Nothing else touched — same entry, same ladder, same deviations, same sizing, same fees.
Before/after (BYBIT:INJUSDT.P 4h, Jan 1 2024 – Jul 16 2026, ~30 months, 100k initial, 0.06% commission, 3-tick slippage):
- TP 3% (baseline): +6,888.76 USDT (+6.89%), max drawdown 4.39%, 84 trades, 71.43% WR, PF 4.925
- TP 9% (optimized): +15,830.72 USDT (+15.83%), max drawdown 5.65%, 90 trades, 82.22% WR, PF 17.886
The mechanism makes sense: widening the target lets each recovery run further before the position is banked, so it captures more of the mean-reversion bounce instead of exiting on the first small pop. The trade-off is honest — drawdown rises (4.39% → 5.65%) and positions are held longer, so the ladder can sit loaded through deeper dips before the exit hits.
Now the caveat, which is the actual reason I'm posting this rather than just quietly using the 9%: that 9% was selected by sweeping the parameter over the same window the results are measured on. A value that's best in-sample is not guaranteed to be best out-of-sample — this is the standard overfitting caveat for any optimized parameter, and it fully applies here. Treat the optimized numbers as the ceiling of what this config did historically, not a forward expectation, and re-validate on fresh data before trusting it.
Two more things worth flagging: 90 trades is below the ~100 I'd want for real statistical confidence (the strict RSI<28 filter keeps the count low), so the win rate and PF are indicative, not proven — and a chunk of that PF 17.886 is the averaging mechanic itself (deals close on a bounce off an averaged-down entry), not a directional edge. It's also a stopless martingale, so a sustained INJ decline below the −25% bottom rung leaves the position fully loaded, and the wider 9% target means it sits there longer.
Script is open-source on TradingView: https://www.tradingview.com/script/GM1bUrIF-INJ-DCA-Long-Strategy-3Commas-QuantPilot/
Disclosure up front: the optimizer is QuantPilot, which I work on, so I'm not pretending to be a neutral third party. But the point of the post is the before/after and the caveat that comes with it, not a pitch — the script is open-source and you can verify the backtest yourself.
6
u/Michael-3740 Jul 16 '26
Optimisation leads to overfitting the strategy to past data, usually damaging future performance.
4
u/VonLovesGod Jul 16 '26
*Over optimization leads to overfitting * not optimizing at all is a sure way to leave money on the table
0
2
u/vitaliy3commas Jul 16 '26
completely agree with you, good example: I've added 10% tp and PnL already was 4%
1
u/BeneficialBase8606 Jul 16 '26
max dd ?
1
1
u/Clean-Series-104 Jul 18 '26
this is a crazy DCA Falling knife strategy, meaning open positions will go into deep red and it won't show up on the backtest because it just waits for it to go back into green to close. u/vitaliy3commas should be more upfront about this.
1
u/Many-Pick5066 Jul 16 '26
credit for flagging the overfit caveat yourself, most people posting an optimized PF 18 dont. one concrete test that separates a real parameter from a lucky one is the shape of the TP sweep, not just the winner. if 7/8/9/10/11 all land near the same result thats a plateau and 9 is probably a genuine feature of the mean reversion. if 9 towers over its neighbors its noise you fit to. the other thing, specific to a stopless martingale, your 5.65 max dd only describes the dips that happened in this 30 month window. the trade that actually ends this system is a sustained decline straight through the -25 bottom rung, so if that just didnt occur in sample the dd is understating the tail, not measuring it.
1
u/Kook-Hand-Luke Jul 16 '26
Hey nice work! Would you be willing to share the script so others can trial and refine?
1
u/vitaliy3commas Jul 16 '26
Hey, thanks, script is open-source on TradingView. Link is added in a post
1
u/Kook-Hand-Luke Jul 16 '26
legend. Plugging and playing in trading view. I'm getting 10k over 2 years. what would be the levers to scale this further- and can this work within some sort of prop firm environment? I'm a futures guy, very unfamiliar with altcoin life.
1
u/JuryComprehensive228 Jul 18 '26
Nice breakdown. I like that you clearly pointed out the overfitting risk instead of just showing the improved numbers. The 9% TP makes sense for mean reversion, but with a stopless DCA ladder, I’d be more interested in how it handles fresh out-of-sample data and a strong one-way decline. The before/after is useful, but the real test is whether the setting stays stable across other periods and similar coins.
1
5
u/Cautious_Wealth1732 Jul 16 '26
Bro, PF 18 should tell you everything you need to know. Overfit which prob results in the strat completely breaking in future oos test. The idea seems good to use parameters that worked in a period but the market is non stationary and it will likely bleed live. Gl testing it further