PINE LIBRARY
OfficalQLBacktestingMetrics

Library "OfficalQLBacktestingMetrics"
TODO: credits to elicobra and bikelife76
curve(disp_ind)
Call function to get a certain curve of your strategy.
Parameters:
disp_ind (string)
Returns: Returns type of curve plot.
quantlapseTable(option, position)
Assign this function to a random variable to get the "Performance Table"
Parameters:
option (simple string)
position (simple string)
OfficialQLBacktestingMetrics is a comprehensive backtesting metrics and visualization library for Pine Script v6.
It provides an advanced set of quantitative performance tools to evaluate and visualize the robustness of any TradingView strategy. Designed for precision and clarity, this library calculates key trading metrics, generates visual performance tables, and applies dynamic color grading to highlight strengths and weaknesses across critical performance dimensions.
🔍 Key Features
Comprehensive Statistical Engine:
Calculates advanced metrics including Sharpe Ratio, Sortino Ratio, Omega Ratio, Profit Factor, Max Equity Drawdown, Intra-Trade Drawdown, Win/Loss consistency, Long/Short profit ratios, and more.
Visual Performance Table:
The quantlapseTable() function creates a fully customizable performance dashboard directly on your chart. Choose between:
Full — displays all available statistics.
Simple — compact view of key performance metrics.
None — hides the table when not needed.
Dynamic Color Grading:
Metrics are visually ranked through gradient color logic to help quickly identify strong vs weak areas in strategy performance.
Curve and Filtering Utilities:
Use curve() and cleaner() to easily access and manage equity curves, profit data, and strategy-specific plots for further analysis or visualization.
Smart Statistical Adjustments:
The library automatically scales statistical measures such as Sharpe and Sortino ratios according to the chart’s timeframe, ensuring accurate normalization across daily, weekly, or intraday data.
Robustness Scoring System (“Slap Score”):
A built-in performance quality evaluator that scores a strategy’s overall robustness based on multiple key performance thresholds.
🧩 Main Functions
Function Description
curve(disp_ind) Returns selected equity or profit curve.
cleaner(disp_ind, plot) Filters plots to show only selected display types.
stat_calc() Core metric computation engine. Returns all major backtesting stats.
quantlapseTable(option, position) Generates performance table (Full, Simple, or None).
f_colors(metric, value) Assigns gradient colors to metrics for visual evaluation.
maxEquityDrawDown() / maxTradeDrawDown() Calculates drawdowns at equity and trade levels.
consecutive_wins() / consecutive_losses() Measures streaks of profitable/unprofitable trades.
long_profit() / short_profit() Evaluates long/short side profitability ratios.
⚙️ Usage Example
//version=6
import QuantLapse/OfficalQLBacktestingMetrics/1 as ql
disp_ind = input.string ("Equity" , title = "Display Curve" , tooltip = "Choose which data you would like to display", options=["Strategy", "Equity", "Open Profit", "Gross Profit", "Net Profit", "None"], group = "🌌𝙌𝙪𝙖𝙣𝙩𝙇𝙖𝙥𝙨𝙚 𝘽𝙖𝙘𝙠𝙩𝙚𝙨𝙩𝙞𝙣𝙜🚀")
pos_table = input.string("Middle Right", "Table Position", options = ["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group = "🌌𝙌𝙪𝙖𝙣𝙩𝙇𝙖𝙥𝙨𝙚 𝘽𝙖𝙘𝙠𝙩𝙚𝙨𝙩𝙞𝙣𝙜🚀")
type_table = input.string("Full", "Table Type", options = ["Full", "Simple", "None"], group = "🌌𝙌𝙪𝙖𝙣𝙩𝙇𝙖𝙥𝙨𝙚 𝘽𝙖𝙘𝙠𝙩𝙚𝙨𝙩𝙞𝙣𝙜🚀")
ql.quantlapseTable("Full", "Top Right")
plot(ql.curve(disp_ind), color = color.teal, linewidth = 2)
ql.quantlapseTable(type_table, pos_table)
🧠 Credits
Created by elicobra and bikelife76 tweaked my QuantLapse
TODO: credits to elicobra and bikelife76
curve(disp_ind)
Call function to get a certain curve of your strategy.
Parameters:
disp_ind (string)
Returns: Returns type of curve plot.
quantlapseTable(option, position)
Assign this function to a random variable to get the "Performance Table"
Parameters:
option (simple string)
position (simple string)
OfficialQLBacktestingMetrics is a comprehensive backtesting metrics and visualization library for Pine Script v6.
It provides an advanced set of quantitative performance tools to evaluate and visualize the robustness of any TradingView strategy. Designed for precision and clarity, this library calculates key trading metrics, generates visual performance tables, and applies dynamic color grading to highlight strengths and weaknesses across critical performance dimensions.
🔍 Key Features
Comprehensive Statistical Engine:
Calculates advanced metrics including Sharpe Ratio, Sortino Ratio, Omega Ratio, Profit Factor, Max Equity Drawdown, Intra-Trade Drawdown, Win/Loss consistency, Long/Short profit ratios, and more.
Visual Performance Table:
The quantlapseTable() function creates a fully customizable performance dashboard directly on your chart. Choose between:
Full — displays all available statistics.
Simple — compact view of key performance metrics.
None — hides the table when not needed.
Dynamic Color Grading:
Metrics are visually ranked through gradient color logic to help quickly identify strong vs weak areas in strategy performance.
Curve and Filtering Utilities:
Use curve() and cleaner() to easily access and manage equity curves, profit data, and strategy-specific plots for further analysis or visualization.
Smart Statistical Adjustments:
The library automatically scales statistical measures such as Sharpe and Sortino ratios according to the chart’s timeframe, ensuring accurate normalization across daily, weekly, or intraday data.
Robustness Scoring System (“Slap Score”):
A built-in performance quality evaluator that scores a strategy’s overall robustness based on multiple key performance thresholds.
🧩 Main Functions
Function Description
curve(disp_ind) Returns selected equity or profit curve.
cleaner(disp_ind, plot) Filters plots to show only selected display types.
stat_calc() Core metric computation engine. Returns all major backtesting stats.
quantlapseTable(option, position) Generates performance table (Full, Simple, or None).
f_colors(metric, value) Assigns gradient colors to metrics for visual evaluation.
maxEquityDrawDown() / maxTradeDrawDown() Calculates drawdowns at equity and trade levels.
consecutive_wins() / consecutive_losses() Measures streaks of profitable/unprofitable trades.
long_profit() / short_profit() Evaluates long/short side profitability ratios.
⚙️ Usage Example
//version=6
import QuantLapse/OfficalQLBacktestingMetrics/1 as ql
disp_ind = input.string ("Equity" , title = "Display Curve" , tooltip = "Choose which data you would like to display", options=["Strategy", "Equity", "Open Profit", "Gross Profit", "Net Profit", "None"], group = "🌌𝙌𝙪𝙖𝙣𝙩𝙇𝙖𝙥𝙨𝙚 𝘽𝙖𝙘𝙠𝙩𝙚𝙨𝙩𝙞𝙣𝙜🚀")
pos_table = input.string("Middle Right", "Table Position", options = ["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group = "🌌𝙌𝙪𝙖𝙣𝙩𝙇𝙖𝙥𝙨𝙚 𝘽𝙖𝙘𝙠𝙩𝙚𝙨𝙩𝙞𝙣𝙜🚀")
type_table = input.string("Full", "Table Type", options = ["Full", "Simple", "None"], group = "🌌𝙌𝙪𝙖𝙣𝙩𝙇𝙖𝙥𝙨𝙚 𝘽𝙖𝙘𝙠𝙩𝙚𝙨𝙩𝙞𝙣𝙜🚀")
ql.quantlapseTable("Full", "Top Right")
plot(ql.curve(disp_ind), color = color.teal, linewidth = 2)
ql.quantlapseTable(type_table, pos_table)
🧠 Credits
Created by elicobra and bikelife76 tweaked my QuantLapse
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.