MomentumResetsMomentumResets is a compact Pine Script library for detecting momentum reset events using finite-state logic.
You get three different reset models that all return one shared exported signal enum, so integration in your own scripts stays simple and consistent.
Advantages of using this library include:
• Unified signal type : All models return the same `Signal` enum (`bullish`, `bearish`, `none`).
• State-driven logic : Explicit states are more robust than brittle one-bar pattern checks.
• Input validation : Built-in runtime checks catch invalid thresholds and shoulder settings early.
• Flexible strictness : Optional `skipValidation` when you need tolerant behaviour for dynamic or partial inputs.
• Model choice : Stoch, Static Level, and Pivot variants cover different momentum structures.
🟩 RESET MODELS
Stoch Reset
Tracks Stoch around upper/lower thresholds and emits resets when momentum rotates with confirmation conditions.
Use this when you want directional reset events, not just overbought/oversold touches.
Static Level Reset
Uses a two-phase path per side around static thresholds with an optional tolerance buffer.
Use this for "break -> return -> re-break" style momentum structures around fixed levels.
Pivot Reset
Uses shoulder distances and trailed extremes to detect retrace/bounce resets after directional expansion.
Use this for swing-style turns where relative move size matters more than absolute levels.
The models are easier to grasp by seeing them than they are to explain. They all have example visualisations included.
🟩 VALIDATION & ERROR HANDLING
The library includes defensive checks with `runtime.error()` messaging for critical misconfiguration.
Examples of guarded inputs:
• Thresholds cannot be `na`.
• Lower threshold must be below upper threshold.
• Stoch thresholds must stay within 0-100.
• Tolerance must be 0 or greater.
• Shoulder distances must be greater than 0.
• Optional pivot bounds are checked for logical consistency when both are used.
Each error message is prefixed with the library + function name to make debugging easier.
🟩 HOW TO USE
Pine Script libraries contain reusable code for importing into indicators. You do not need to copy any code out of here. Just import the library and call the function you want.
For version 1, import it like this:
import SimpleCryptoLife/MomentumResets/1
Then call one reset function per model/series path each bar, and route the returned `Signal` enum into your entries, exits, filters, or alerts.
For more information on libraries and incorporating them into your scripts, see the Libraries section of the Pine Script User Manual.
🟩 BRING ON THE FUNCTIONS
getStochResetSignal(_stochK, _stochD, _lowerThreshold, _upperThreshold, _skipValidation)
Returns a Stoch momentum reset signal using internal FSM states (neutral, tracking, suppressed).
Parameters:
_stochK (float)
Current Stoch %K value used in state transitions.
_stochD (float)
Current Stoch %D value used for confirmation logic.
_lowerThreshold (float, default 20.0)
Lower Stoch threshold used for setup and reset detection.
_upperThreshold (float, default 80.0)
Upper Stoch threshold used for setup and reset detection.
_skipValidation (bool, default false)
If true, skips guard checks and allows tolerant execution with dynamic/partial inputs.
Returns: Signal (`Signal.bullish`, `Signal.bearish`, or `Signal.none` for this bar).
getStaticLevelResetSignal(_value, _lowerThreshold, _upperThreshold, _tolerance, _skipValidation)
Returns a reset signal when value completes the threshold/tolerance path on either side.
Parameters:
_value (float)
Current series value to evaluate.
_lowerThreshold (float)
Lower static level used by the bullish reset path.
_upperThreshold (float)
Upper static level used by the bearish reset path.
_tolerance (float, default 0.0)
Optional buffer zone around levels before a reset can complete.
_skipValidation (bool, default false)
If true, skips guard checks and allows tolerant execution with dynamic/partial inputs.
Returns: Signal (`Signal.bullish`, `Signal.bearish`, or `Signal.none` for this bar).
getPivotResetSignal(_value, _leftShoulder, _rightShoulder, _bearMinHeight, _bullMaxDepth, _skipValidation)
Returns a reset signal using shoulder-based priming and trailing extremes for pivot-style turns.
Parameters:
_value (float)
Current series value to evaluate.
_leftShoulder (float)
Relative move from anchor required to prime a directional setup.
_rightShoulder (float)
Relative retrace/bounce from the trailed extreme required to trigger a reset.
_bearMinHeight (float, optional)
Optional absolute minimum high required before bearish resets are allowed.
_bullMaxDepth (float, optional)
Optional absolute maximum low required before bullish resets are allowed.
_skipValidation (bool, default false)
If true, skips guard checks and allows tolerant execution with dynamic/partial inputs.
Returns: Signal (`Signal.bullish`, `Signal.bearish`, or `Signal.none` for this bar).
Bibliothèque Pine Script®






















