reimadara

Strategy VS Buy & Hold

reimadara 업데이트됨   
SUMMARY:
A strategy wrapper that makes a detailed and visual comparison between a given strategy and the buy & hold returns of the traded security.


DESCRIPTION:
TradingView has a "Buy & Hold Return" metric in the strategy tester that is often enough to assess how our strategy compares to a simple buy hold. However, one may want more information on how and when your strategy beats or is beaten by a simple buy & hold strategy. This script aims to show such detail by providing a more comprehensive metrics and charting the profit/loss of the given strategy against buy & hold.

As seen in the script, it plots/draws 4 elements:

1) Strategy P/L: strategy net profit + strategy open profit
2) Buy & Hold P/L: unrealized return
3) Difference: Strategy P/L - Buy & Hold P/L
4) Strategy vs Buy Hold Stats
> Percent of bars strategy P/L is above Buy & Hold
> Percent of bars strategy P/L is below Buy & Hold
> All Time Average Difference


ADJUSTABLE PARAMETERS:
All labels/panels can be disabled by unchecking these two options:
>bnh_info_panel = input(true, title='Enable Info Panel')
>bnh_indicator_panel = input(true, title='Enable Indicator Panel')

Comparison Date Range can be changed to better isolate specific areas:
>From Year, From Month, From Day
default: 1970 01 01

>To Year, To Month, To Day
default: 2050 12 31

Default settings basically covers all historical data.


HOW TO USE:

The default script contains a simple 50-200 SMA cross strategy, just delete and replace it. Those are everything between these lines:
/////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////STRATEGY SCRIPT START//////////////////////////////////

(STRATEGY SCRIPT GOES HERE)

//////////////////////////////STRATEGY SCRIPT END////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

Removing all plots and drawings from your strategy is advisable.

If you are going to use the Comparison Date Range, apply "bnh_timeCond" to your strategy to align the dates. A sample on how it’s applied can be seen on the Placeholder MA cross strategy.
Note: bnh_timeCond returns a boolean series
릴리즈 노트:
-Updated to Pine v5.

오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?