OPEN-SOURCE SCRIPT
LSMA25 Trend Correction Continuation

## LSMA25 Trend Correction Continuation - Publishing Description
### Overview
This indicator highlights **trend continuation opportunities** using a **25-period LSMA (Least Squares Moving Average)** with a **slope/angle filter** and a simple **correction + re-entry** logic.
It is designed to mark:
* **Continuation entries** after a pullback (correction) and re-cross of LSMA in the direction of a strong trend
* **Strong-trend state** (subtle dots) when price stays on the trend side of LSMA with a steep angle, even without a fresh cross
### Core logic
1. **LSMA (25 by default)**
* Uses `ta.linreg(close, lsmaLen, 0)` as the LSMA line.
2. **Trend strength via angle (tick-normalized)**
* Computes 1-bar LSMA slope in **ticks**:
* `slopeTicks = (lsma - lsma[1]) / syminfo.mintick`
* Converts slope to an angle using `atan()` and a calibration input:
* `ticksPerBarFor45` approximates how many ticks per bar corresponds to ~45°
* Strong trend conditions:
* LONG trend strength when `angleDeg >= minAngleLongDeg`
* SHORT trend strength when `angleDeg <= minAngleShortDeg`
3. **Correction detection**
* LONG side: a correction exists if within the last `corrLookback` bars the close was **below** LSMA:
* `ta.barssince(close < lsma) <= corrLookback`
* SHORT side: correction exists if within the last `corrLookback` bars the close was **above** LSMA:
* `ta.barssince(close > lsma) <= corrLookback`
4. **Continuation signals**
* **Long Continuation (LC)** triggers when:
* Price **crosses above** LSMA (`ta.crossover(close, lsma)`)
* Angle indicates **strong uptrend**
* A recent **pullback below LSMA** occurred
* Optional ATR% filter passes
* **Short Continuation (SC)** triggers symmetrically on cross below.
5. **Strong trend markers**
* When price is on the trend side of LSMA and angle is strong:
* Uptrend: `close > lsma and strongUp`
* Downtrend: `close < lsma and strongDown`
* Drawn as small, semi-transparent circles (not entry signals by themselves).
### Plots and labels
* **LSMA line** plotted in yellow.
* **LC**: green triangle below bar (trend continuation long).
* **SC**: red triangle above bar (trend continuation short).
* **Dots**: tiny circles for strong-trend state when no fresh continuation signal is present.
### Inputs (how to tune)
* **LSMA length**
* Higher = smoother, fewer signals
* Lower = more responsive, more signals/noise
* **Ticks per bar ≈ 45°**
* Calibration control for angle scaling across different instruments/timeframes
* Increase it if angles look too “aggressive”; decrease it if angles look too “flat”
* **Min angle for LONG / Max angle for SHORT**
* Tighten to filter for only steep trends; loosen to allow more setups
* **Max correction bars back**
* Larger values allow older pullbacks to qualify
* Smaller values require a more recent correction
### Optional volatility filter (ATR%)
* When enabled, the script requires:
* `ATR% = (ATR / close) * 100 >= minAtrPct`
* Useful to avoid low-volatility chop (but can filter out valid trends on slow markets).
### How to use (practical)
* Use **LC/SC** as “trend continuation after pullback” markers:
* Prefer trading in the direction of higher timeframe bias (if applicable)
* Consider entries on LC/SC with your own risk rules (stops/targets are not included)
* Use the **strong-trend dots** as a regime filter:
* If dots persist, continuation setups have higher context quality
* If dots disappear frequently, market may be ranging/choppy
### Limitations (important)
* Angle is based on **LSMA 1-bar slope**, so it is sensitive to sudden changes and can vary across markets/timeframes.
* Correction logic is binary: it only checks whether price crossed to the other side of LSMA recently (not depth/structure of pullback).
* Signals depend on **close crossing LSMA**, not intrabar wick behavior.
* Not a full trading system: no position sizing, stops, or take profits.
### Alerts
Alerts fire only on **confirmed bars** (`barstate.isconfirmed`) for:
* “LSMA25 Long continuation”
* “LSMA25 Short continuation”
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.