Seungdori_

Grid Strategy Back Tester (Long/Short/Neutral)

Seungdori_ 已更新   
Preface
I'd like to send a thank you to @xxattaxx-DisDev.
The 'Line' Code, which was the most difficult to plan the Grid Indicator, was solved through the 'Grid Bot Simulator' script of @xxattaxx-DisDev.


A brief description of the indicators
These indicators are designed for backtesting of grid trading that can be opened on various exchanges.

Grid trading is a method of selling at particular intervals as prices rise and fall for gird interval price range.
This indicator is actually designed to see what the Long / Short / Neutral grid has achieved and how much it has achieved over a given period of time.


How to use

1. Lower Limit and Upper Limit are required when putting indicators on the chart.
After that, choose the 'Time' when to open the grid.
Also, select Long / Short / Neutral direction if necessary.

2. Statistics Table


Matched Grid shows how many grid pairs were engaged during the backtesting period.
The Daily Average Matching Profit is calculated based on the number of these closed grids.

Total Matching Profit is calculated as Matching Grid * Per Matching Profit.

Position Profit/Loss shows the benefits and losses from your current position.

Total Profit/Loss is sum of Total Matching Profit and Position Profit/Loss.

The Expanded APY shows the benefits of running the strategy on these terms for a year.

Max Loss of Upper is the maximum loss assumed to be directly at the top of the grid range.
BEP days (Upper) show how many days of maintenance relative to Average Matching Profit can result in greater profit than maximum loss if the grid continues to move within range.
(In the case of Long Strategy, it appears to be 'Min Profit', which shows minimal benefit if it reaches the top.)

Max Loss of Lower and BEP days (Lower) shows the opposite.
(In the case of Short Strategy, it is also referred to as 'Min Profit', which shows minimal benefit if it reaches the bottom.)

3. Grid Info


Total Grid Number, Upper Limit, and Lower Limit show the values you set in INPUT.

Grid Open Price shows the price for the period you decide to open.

Starting Position shows the number of positions that were initially held in the case of a Long / Short Strategy.
(0 for Neutral Strategy)

Per Grid qty shows how many positions are allocated to one grid
Grid Interval shows the spacing of each grid.
Per Matched Profit shows how much profit is generated when a single grid is matched.

Caution

Backtesting results for these indicators may vary depending on the time frame.
Therefore, I recommend that you use it only to compare Profit/Loss over time.

*In addition, there is a problem that all lines in the grid are not implemented, but it is independent of the backtest results.





--------------------------------------

서문

지표를 기획함에 있어서 가장 어려웠던 line 코드를 @xxattaxx-DisDev의 'Grid Bot Simulator' 스크립트를 통해 해결할 수 있었습니다.

이에 감사의 말씀을 드립니다.

해당 지표에 대한 간단한 설명
해당 지표는 다양한 거래소에서 오픈할 수 있는 그리드 매매에 대한 백테스팅을 위해 만들어졌습니다.
그리드매매는, 특정 가격 구간에 대해 가격이 오르고 내림에 따라 일정 간격에 맞춰 매매를 하는 방식입니다.
이 지표는 실질적으로 롱/숏/중립 그리드가 어떠한 성과를, 특정 기간동안 얼마나 냈는지를 확인하고자 만들어졌습니다.

사용방법

1. 인풋

지표를 차트위에 넣을 때, Lower Limit과 Upper Limit이 필요합니다.
그 후 그리드를 언제부터 오픈할 것인지를 선택하세요.
또, 필요하다면 Long / Short / Neutral의 방향을 선택하세요.

2. 그리드 통계

Matched Grid는, 백테스팅 기간동안 체결된 그리드 쌍이 몇개인지를 보여줍니다.
이 체결된 그리드의 갯수를 바탕으로 Daily Average Matched Profit이 계산됩니다.

Total Matched Profit은, Matched Grid * Per Matched Profit으로 계산됩니다.

Position Profit/Loss는, 현재 갖고 있는 포지션으로 인한 이익과 손실을 보여줍니다.

Total Matched Profit과 Position Profit/Loss를 합친 금액이 Total Profit/Loss가 됩니다.

Expcted APY는, 이러한 조건으로 전략을 1년동안 운영했을 때의 이익을 보여줍니다.

Max Loss of Upper는, 그리드 범위의 최상단에 바로 도달했을 경우를 가정한 최대 손실입니다.
BEP days(Upper)는, 그리드가 범위 내에서 계속 움직일 경우, Average Matched Profit을 기준으로 며칠동안 유지되어야 최대손실보다 더 큰 이익이 발생할 수 있는지를 보여줍니다.
(Long Strategy의 경우, ‘Min Profit’이라고 나타나는데, 최상단에 도달했을 경우 최소한의 이익을 보여줍니다)

Max Loss of Lower는 그 반대의 경우를 보여줍니다.
(Short Strategy의 경우, 역시 ‘Min Profit’이라고 나타나는데, 최하단에 도착했을 경우 최소한의 이익을 보여줍니다)

3. 그리드 정보
그리드 갯수, Upper Limt, Lower Limt은 자신이 설정한 값을 보여줍니다.

Grid Open Price는, 자신이 오픈하기로 정했던 기간의 가격을 보여줍니다.

Starting Position은, 롱/숏 그리드의 경우에 처음에 들고 시작했던 포지션의 갯수를 보여줍니다.
Neutral Strategy의 경우 0입니다.

Per Grid qty는, 하나의 그리드에 얼마만큼의 포지션이 배분되었는지를 보여주며
Grid Interval은 각 그리드의 간격을 보여줍니다.
또, Per Matched Profit은 하나의 그리드가 체결될 때 얼마만큼의 이익이 발생하는 지를 보여줍니다.




이러한 지표에 대한 역테스트 결과는 시간 프레임에 따라 달라질 수 있습니다.
따라서 시간 경과에 따른 손익을 비교할 때만 사용하는 것이 좋습니다.
*추가로, 그리드의 라인이 모두 구현되지 않는 문제가 있지만, 백테스팅 결과와는 무관합니다.
版本注释:
Thanks to @xxattaxx-DisDev

Line problem solved.

And I got put on 'DrawDown' on table.

When Max Draw Down is bigger than your Initial Capital, the 'Max Draw Down' will show red text color.
版本注释:
Improved the calculation formula to make the backtest results more accurate.
版本注释:
Upgraded to show when able to liquidation on background color.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?