Dynamic TPSL
Take-profit and stop-loss ratios that widen or tighten with the market regime and momentum.
DynamicTPSL outputs a take-profit ratio and a stop-loss ratio from two inputs: a regime code and a momentum reading. Its two base values from params are scaled by regime: regime 2 (parabolic) multiplies take-profit by 4.0 and stop-loss by 0.75, regime 1 (high-volatility crash) by 2.5 and 0.9, and any other regime (calm) by 1.0 and 1.1. Momentum above 0.8 multiplies take-profit by a further 1.5, and momentum above 0.6 (but not above 0.8) by 1.3; momentum never changes stop-loss, and missing momentum counts as zero. The code has no symbol-specific logic, and the indicator returns nothing when the regime input is missing.
How to read it
- Both lines sit in their own panes below the price, as ratios (0.45 means 45%), not as price levels.
- Take-profit steps up with the regime: about 0.3 in calm, 0.75 in a crash and 1.2 when parabolic at default settings, then steps again with momentum.
- Stop-loss moves the other way: about 0.055 in calm, 0.045 in a crash and 0.0375 when parabolic at default settings.
- A flat line means the inputs stayed in one branch; in the default SPY sample both lines never moved.
What it outputs
- Take-profit ratio
- Base take-profit scaled by regime and momentum. Default settings give 0.3 in calm markets and up to 1.8 when parabolic with strong momentum.
- Stop-loss ratio
- Base stop-loss scaled by regime only. Default settings give 0.055 in calm markets, tighter at 0.045 in a crash and 0.0375 when parabolic.
Settings
- base_tp
- Base take-profit before regime and momentum scale it (default 0.3). Raising it lifts every take-profit target in proportion; lowering it pulls them all closer. The slider allows negatives, which give meaningless targets.
- base_sl
- Base stop-loss before regime scales it (default 0.05). Raising it widens every stop proportionally, lowering it tightens them all. The slider allows negatives, which give meaningless stops.
Pitfalls
- Flat on the default SPY sample: both lines held 0.45 and 0.055 for a month, so the numbers imply calm regime with momentum above 0.8 on every bar. Check the feeding indicators before relying on the lines.
- The sliders allow base take-profit from -31 to 31 and base stop-loss from -6 to 6. Keep both positive and realistic; values far outside a sensible ratio give meaningless targets and stops.
- The indicator returns ratios and does not say how the strategy applies them to price; confirm that convention in the strategy that uses it before reading the lines as price distances.