PINE LIBRARY
업데이트됨 CobraMetrics

Library "CobraMetrics" :
This Library was made to ease the implementation of the "Coded Metrics Table" for strategy evaluation, as well as the plotting asthetics for it's "Equity Curve" that is used for indexing.
Moreover, it will boost your code's efficiency by reducing it of somewhere around 200 lines.
curve(disp_ind)
Call this function in a plot() to get a certain curve of your strategy, depending on your "disp_ind" input.
Parameters:
disp_ind
Returns: curve of your selection
cleaner(disp_ind, plot)
Call this function in your Strategy's plot() lines to filter out your Strategy plots when displaying equity or any other curve.
Parameters:
disp_ind
plot : the variable you want to plot.
cobraTable()
Call this function to get the "Cobra Table" of your strategy
Special thanks to ShauryaM14 for the cell calculatons.
Simply copy paste the following into your strategy script
Pine Script®
I have decided to add the following metrics on top of the usual ones since they provide you with a clearer POV of your strategy,
to decide if it fits your trading\investing style. Although, they are not included in the evaluation of a ⚡💫 𝙎𝙎𝙎𝙡𝙖𝙥𝙥𝙚𝙧 💫⚡.
Net Profit Long\Short Ratio - Theoretically, a good strategy has a fair balance between both sides of its trading directions. Clearly this is subjective since most assets are assymetrical and some people challenge the idea of a strategy trading both ways. Still, it gives useful insight.
Max Consecutive Wins\Losses - Checks for consistancy in the strategy
Max Flat Days - Gives an approximation of how fast\slow the strategy is. Are you patient enough to wait that long till your strategy fires? Irrelevant for fully perpetual strategies (Those which are always in a position, switch from one direction to the other. The alternatives are called semi perps)
Total Months in Profit\Loss - Are you able to financialy withstand that long in a loss? Are you able to manage your capital correctly in the winning period to minimize potential losses?
This Library was made to ease the implementation of the "Coded Metrics Table" for strategy evaluation, as well as the plotting asthetics for it's "Equity Curve" that is used for indexing.
Moreover, it will boost your code's efficiency by reducing it of somewhere around 200 lines.
curve(disp_ind)
Call this function in a plot() to get a certain curve of your strategy, depending on your "disp_ind" input.
Parameters:
disp_ind
Returns: curve of your selection
cleaner(disp_ind, plot)
Call this function in your Strategy's plot() lines to filter out your Strategy plots when displaying equity or any other curve.
Parameters:
disp_ind
plot : the variable you want to plot.
cobraTable()
Call this function to get the "Cobra Table" of your strategy
Special thanks to ShauryaM14 for the cell calculatons.
Simply copy paste the following into your strategy script
import EliCobra/CobraMetrics/4 as cobra
//// PLOT DATA
disp_ind = input.string ("None" , 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 Left", "Table Position", options = ["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
type_table = input.string("None", "Table Type", options = ["Full", "Simple", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
plot(cobra.curve(disp_ind))
cobra.cobraTable(type_table, pos_table)
I have decided to add the following metrics on top of the usual ones since they provide you with a clearer POV of your strategy,
to decide if it fits your trading\investing style. Although, they are not included in the evaluation of a ⚡💫 𝙎𝙎𝙎𝙡𝙖𝙥𝙥𝙚𝙧 💫⚡.
Net Profit Long\Short Ratio - Theoretically, a good strategy has a fair balance between both sides of its trading directions. Clearly this is subjective since most assets are assymetrical and some people challenge the idea of a strategy trading both ways. Still, it gives useful insight.
Max Consecutive Wins\Losses - Checks for consistancy in the strategy
Max Flat Days - Gives an approximation of how fast\slow the strategy is. Are you patient enough to wait that long till your strategy fires? Irrelevant for fully perpetual strategies (Those which are always in a position, switch from one direction to the other. The alternatives are called semi perps)
Total Months in Profit\Loss - Are you able to financialy withstand that long in a loss? Are you able to manage your capital correctly in the winning period to minimize potential losses?
릴리즈 노트
v2Updated customization, corrected calculation of some metrics to work on different timeframes (hopefully I did it right).
This one will be slightly harder to achieve slapper status, good luck.
릴리즈 노트
v31. Addressed the visual overlapping of cells on smaller screens, such as laptops. (Even works on mobile lol)
2. Added the option to switch display between "Full" and "Simple" layouts, can also hide the table completely.
3. Added the functionality to change the position where the table will be anchored.
4. Increased the variety of timeframes the anual metrics such as Sharpe, Sortino and Omega will be calculated correctly.
5. Added Net Profit % metric. (Friendly reminder to optimize for efficiency)
릴리즈 노트
v4Omega Ratio correction update.
Slapper Value = 1.35
GL
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.