OPEN-SOURCE SCRIPT

Avg High/Low Lines with TP & SL

164
아래 코드는 TradingView Pine Script v6으로 작성된 스크립트로, 주어진 캔들 수 동안의 평균 고가와 저가를 계산해서 그 위에 수평선을 그리며, 해당 수평선 돌파 시 진입 가격을 기록하고, 손절가(SL)와 목표가(TP)를 자동으로 계산하여 표시하는 전략입니다. 알림(alert) 기능도 포함되어 있습니다.

코드 주요 기능 요약
length 기간 동안 평균 고가, 저가를 단순 이동평균(SMA)으로 계산

평균 고가선, 저가선 수평선을 일정 바 개수만큼 좌우 연장하여 차트에 표시

평균 고가 돌파 시 매수 진입, 평균 저가 돌파 시 매도 진입 처리

진입 가격 저장 및 상태 관리 (inLong, inShort 플래그)

손절가(SL): 롱이면 평균 저가, 숏이면 평균 고가

목표가(TP): 진입가에서 손절 거리의 1.5배만큼 설정

진입가 기준으로 TP, SL 라인과 라벨 표시

상단 돌파 후 종가 마감 시 매수 알림, 하단 돌파 후 종가 마감 시 매도 알림


Sure! Here’s the English explanation of your TradingView Pine Script v6 code:

Summary of Key Features
Calculates the simple moving average (SMA) of the high and low prices over a user-defined number of candles (length).

Draws horizontal lines for the average high and average low, extending them a specified number of bars to the left and right on the chart.

Detects breakouts above the average high to trigger a long entry, and breakouts below the average low to trigger a short entry.

Records the entry price and manages trade states using flags (inLong, inShort).

Sets the stop loss (SL) at the average low for long positions, and at the average high for short positions.

Calculates the take profit (TP) level based on the entry price plus 1.5 times the stop loss distance.

Draws lines and labels for the TP and SL levels starting from the entry bar, extended to the right.

Sends alerts when the price closes above the average high after a breakout (long signal), or closes below the average low after a breakout (short signal).


-onestar-

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.