Library "analytics_tables" 📝 Description This library provides the implementation of several performance-related statistics and metrics, presented in the form of tables. The metrics shown in the afforementioned tables where developed during the past years of my in-depth analalysis of various strategies in an atempt to reason about the performance of each strategy. The visualization and some statistics where inspired by the existing implementations of the "Seasonality" script, and the performance matrix implementations of QuantNomad and ZenAndTheArtOfTrading scripts. While this library is meant to be used by my strategy framework "Template Trailing Strategy (Backtester)" script, I wrapped it in a library hoping this can be usefull for other community strategy scripts that will be released in the future.
🤔 How to Guide To use the functionality this library provides in your script you have to import it first! Copy the import statement of the latest release by pressing the copy button below and then paste it into your script. Give a short name to this library so you can refer to it later on. The import statement should look like this:
There are three types of tables provided by this library in the initial release. The stats table the metrics table and the seasonality table. Each one shows different kinds of performance statistics.
The table UDT shall be initialized once using the `init()` method. They can be updated using the `update()` method where the updated data UDT object shall be passed. The data UDT can also initialized and get updated on demend depending on the use case
A code example for the StatsTable is the following:
🏋️♂️ Please refer to the "EXAMPLE" regions of the script for more advanced and up to date code examples!
Special thanks to Mrcrbw for the proposal to develop this library and DCNeu for the constructive feedback 🏆.
getTablePos(ypos, xpos) Get table position compatible string Parameters: ypos (simple string): The position on y axise xpos (simple string): The position on x axise Returns: The position to be passed to the table
method init(this, pos, height, width, positiveTxtColor, negativeTxtColor, neutralTxtColor, positiveBgColor, negativeBgColor, neutralBgColor) Initialize the stats table object with the given colors in the given position Namespace types: StatsTable Parameters: this (StatsTable): The stats table object pos (simple string): The table position string height (simple float): The height of the table as a percentage of the charts height. By default, 0 auto-adjusts the height based on the text inside the cells width (simple float): The width of the table as a percentage of the charts height. By default, 0 auto-adjusts the width based on the text inside the cells positiveTxtColor (simple color): The text color when positive negativeTxtColor (simple color): The text color when negative neutralTxtColor (simple color): The text color when neutral positiveBgColor (simple color): The background color with transparency when positive negativeBgColor (simple color): The background color with transparency when negative neutralBgColor (simple color): The background color with transparency when neutral
method init(this, pos, height, width, neutralBgColor) Initialize the metrics table object with the given colors in the given position Namespace types: MetricsTable Parameters: this (MetricsTable): The metrics table object pos (simple string): The table position string height (simple float): The height of the table as a percentage of the charts height. By default, 0 auto-adjusts the height based on the text inside the cells width (simple float): The width of the table as a percentage of the charts width. By default, 0 auto-adjusts the width based on the text inside the cells neutralBgColor (simple color): The background color with transparency when neutral
method init(this, seas) Initialize the seasonal data Namespace types: SeasonalData Parameters: this (SeasonalData): The seasonal data object seas (simple Seasonality): The seasonality of the matrix data
method init(this, data, pos, maxNumOfYears, height, width, extended, neutralTxtColor, neutralBgColor) Initialize the seasonal table object with the given colors in the given position Namespace types: SeasonalTable Parameters: this (SeasonalTable): The seasonal table object data (SeasonalData): The seasonality data of the table pos (simple string): The table position string maxNumOfYears (simple int): The maximum number of years that fit into the table height (simple float): The height of the table as a percentage of the charts height. By default, 0 auto-adjusts the height based on the text inside the cells width (simple float): The width of the table as a percentage of the charts width. By default, 0 auto-adjusts the width based on the text inside the cells extended (simple bool): The seasonal table with extended columns for performance neutralTxtColor (simple color): The text color when neutral neutralBgColor (simple color): The background color with transparency when neutral
method update(this, wins, losses, numOfInconclusiveExits) Update the strategy info data of the strategy Namespace types: StatsData Parameters: this (StatsData): The strategy statistics object wins (SideStats) losses (SideStats) numOfInconclusiveExits (int): The number of inconclusive trades
method update(this, stats, positiveTxtColor, negativeTxtColor, negativeBgColor, neutralBgColor) Update the stats table object with the given data Namespace types: StatsTable Parameters: this (StatsTable): The stats table object stats (StatsData): The stats data to update the table positiveTxtColor (simple color): The text color when positive negativeTxtColor (simple color): The text color when negative negativeBgColor (simple color): The background color with transparency when negative neutralBgColor (simple color): The background color with transparency when neutral
method update(this, stats, buyAndHoldPerc, positiveTxtColor, negativeTxtColor, positiveBgColor, negativeBgColor) Update the metrics table object with the given data Namespace types: MetricsTable Parameters: this (MetricsTable): The metrics table object stats (StatsData): The stats data to update the table buyAndHoldPerc (float): The buy and hold percetage positiveTxtColor (simple color): The text color when positive negativeTxtColor (simple color): The text color when negative positiveBgColor (simple color): The background color with transparency when positive negativeBgColor (simple color): The background color with transparency when negative
method update(this) Update the seasonal data based on the season and eon timeframe Namespace types: SeasonalData Parameters: this (SeasonalData): The seasonal data object
method update(this, data, positiveTxtColor, negativeTxtColor, neutralTxtColor, positiveBgColor, negativeBgColor, neutralBgColor, timeBgColor) Update the seasonal table object with the given data Namespace types: SeasonalTable Parameters: this (SeasonalTable): The seasonal table object data (SeasonalData): The seasonal cell data to update the table positiveTxtColor (simple color): The text color when positive negativeTxtColor (simple color): The text color when negative neutralTxtColor (simple color): The text color when neutral positiveBgColor (simple color): The background color with transparency when positive negativeBgColor (simple color): The background color with transparency when negative neutralBgColor (simple color): The background color with transparency when neutral timeBgColor (simple color): The background color of the time gradient
SideStats Object that represents the strategy statistics data of one side win or lose Fields: numOf (series int) sumFreeProfit (series float) freeProfitStDev (series float) sumProfit (series float) profitStDev (series float) sumGain (series float) gainStDev (series float) avgQuantityPerc (series float) avgCapitalRiskPerc (series float) avgTPExecutedCount (series float) avgRiskRewardRatio (series float) maxStreak (series int)
StatsTable Object that represents the stats table Fields: table (series table): The actual table rows (series int): The number of rows of the table columns (series int): The number of columns of the table
StatsData Object that represents the statistics data of the strategy Fields: wins (SideStats) losses (SideStats) numOfInconclusiveExits (series int) avgFreeProfitStr (series string) freeProfitStDevStr (series string) lossFreeProfitStDevStr (series string) avgProfitStr (series string) profitStDevStr (series string) lossProfitStDevStr (series string) avgQuantityStr (series string)
MetricsTable Object that represents the metrics table Fields: table (series table): The actual table rows (series int): The number of rows of the table columns (series int): The number of columns of the table
SeasonalTable Object that represents the seasonal table Fields: table (series table): The actual table headRows (series int): The number of head rows of the table headColumns (series int): The number of head columns of the table eonRows (series int): The number of eon rows of the table seasonColumns (series int): The number of season columns of the table statsRows (series int) statsColumns (series int): The number of stats columns of the table rows (series int): The number of rows of the table columns (series int): The number of columns of the table extended (series bool): Whether the table has additional performance statistics
진정한 TradingView 정신에 따라, 저자는 이 파인 코드를 다른 파인 프로그래머들이 재사용할 수 있도록 오픈 소스 라이브러리로 공개했습니다. 저자에게 박수를 보냅니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈 소스 출판물에서 사용할 수 있지만, 이 코드를 출판물에서 재사용하는 것은 하우스 룰에 의해 관리됩니다.