PINE LIBRARY
Updated historicalEngine by N&M

🇬🇧 English Introduction
historicalEngine is a Pine Script library designed for advanced state-based backtesting.
It does not test a single strategy, but evaluates full market configurations (trend, structure, momentum, multi-TF context).
Each trade is linked to a unique state hash, revealing which conditions truly perform over time.
The engine computes professional metrics: PnL, win rate, expectancy, Sharpe, drawdown, reliability.
It includes dynamic TP/SL, liquidation logic, early exits, realistic fees and slippage.
Built to be modular, extensible, and efficient, it plugs into any indicator.
Goal: turn historical data into a statistical trading edge.
V1 – a solid foundation for adaptive and data-driven trading systems.
historicalEngine is a Pine Script library designed for advanced state-based backtesting.
It does not test a single strategy, but evaluates full market configurations (trend, structure, momentum, multi-TF context).
Each trade is linked to a unique state hash, revealing which conditions truly perform over time.
The engine computes professional metrics: PnL, win rate, expectancy, Sharpe, drawdown, reliability.
It includes dynamic TP/SL, liquidation logic, early exits, realistic fees and slippage.
Built to be modular, extensible, and efficient, it plugs into any indicator.
Goal: turn historical data into a statistical trading edge.
V1 – a solid foundation for adaptive and data-driven trading systems.
Release Notes
v2Release Notes
v3Release Notes
v4Release Notes
v5Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.