PROTECTED SOURCE SCRIPT

Disparity(20MA) ±1 × Stochastic 80/20 + ATR SL/TP[by Irum]

62
Disparity(20MA) ±1 × Stochastic 80/20 + ATR SL/TP
사용 설명서 (KR/EN Bilingual Manual)
1) 목적 & 정의 / Purpose & Definition

KR — 목적 & 정의
이 스크립트는 이격도(Disparity) 와 스토캐스틱(80/20) 의 동시 신호를 활용해 추세 전환/지속 구간의 고확률 진입 시점을 포착하고, ATR 기반 손절/익절(고정 또는 트레일링)로 리스크를 정량화하여 운용 효율을 높이기 위해 설계되었습니다.

핵심 아이디어:

가격이 20MA 대비 ±임계값을 크로스(과열/침체 해소 신호)하고,

스토캐스틱이 80/20을 돌파/이탈(모멘텀 전환 신호)할 때,

두 신호가 동일봉 또는 N봉 내 동기화되면 진입.

청산: ATR×배수를 이용한 고정 TP/SL 또는 ATR 트레일링.

EN — Purpose & Definition
This strategy combines Disparity (price vs. 20MA) and Stochastic (80/20) to identify high-probability entries when momentum confirms mean-reversion/continuation, while ATR-based stops/take-profits (fixed or trailing) provide quantified risk control.

Core Idea:

Disparity crosses ±threshold (overbought/oversold release),

Stochastic crosses 80/20 (momentum shift),

Both conditions sync on the same bar or within N bars → entry.

Exits: Fixed ATR TP/SL or ATR trailing.

2) 신호 로직 요약 / Signal Logic Overview

KR

롱 진입: Disparity가 −임계값 상향 돌파 & Stochastic 20 상향 돌파가 syncBars 이내에 동시 충족.

숏 진입: Disparity가 +임계값 하향 돌파 & Stochastic 80 하향 돌파가 syncBars 이내에 동시 충족.

완화 옵션(useRelaxStoch): 최근 relaxLookback 내 20/80 터치 이력 + 현재 방향성만으로도 모멘텀 전환을 인정(교차 미충족 보완).

EN

Long: Disparity crosses up −threshold & Stochastic crosses up 20 within syncBars.

Short: Disparity crosses down +threshold & Stochastic crosses down 80 within syncBars.

Relaxed option (useRelaxStoch): Accepts momentum shift if 20/80 was touched in the last relaxLookback bars and the current slope confirms, even without a strict cross.

3) 설정 메뉴 안내 / Settings Menu Guide
A. 기본 / Core

기준가격 / Source (source)

설명: Disparity 계산에 쓰는 가격 소스.

입력: close, hl2, ohlc4 등.

기본값: close.

팁: 변동성 큰 종목은 hlc3/ohlc4가 노이즈를 줄이기도 함.

이격도 기준 MA 길이 / MA Length (for Disparity) (int ≥1)

설명: Disparity의 기준선이 되는 단순이동평균 길이.

기본값: 20.

영향: 길이↑ → 신호 빈도↓, 안정성↑.

이격도 임계값(±%) / Disparity Threshold (±%) (float ≥0.1, step 0.1)

설명: Disparity가 +임계값 아래로 하향 크로스(숏) 또는 −임계값 위로 상향 크로스(롱)할 때 신호.

기본값: 1.0%.

팁: 너무 크면 신호 드뭄, 너무 작으면 과다.

B. 스토캐스틱 / Stochastic

%K Length / K 길이 (int ≥1, 기본 14)

%K Smoothing / K 스무딩 (int ≥1, 기본 1)

%D Length / D 길이 (int ≥1, 기본 3)

설명: ta.stoch의 K를 스무딩한 kSlow와, 추가 스무딩한 dSlow(참조용)를 구성.

Buy Level (↑20) / 매수 기준선 (0~100, 기본 20)

Sell Level (↓80) / 매도 기준선 (0~100, 기본 80)

C. 신호 로직 / Signal Logic

Signal Sync Window (bars) / 신호 동기화 윈도우 (0~10, 기본 0)

설명: 0=두 신호가 같은 봉에서 모두 충족해야 함. N>0=최근 N봉 내에서 각각 한 번 발생하면 인정.

팁: 1~3은 현실적 체결/지연을 반영하며 과최적화 방지에 도움.

Relaxed Stochastic? (교차 완화) (bool, 기본 false)

설명: 교차 대신 최근 20/80 터치 + 현재 기울기만으로도 모멘텀 전환을 인정. 신호 빈도↑.

Relax lookback bars (int ≥1, 기본 5)

설명: 완화판정에 쓰는 최근 봉 수.

D. 리스크 / Risk (ATR)

ATR Length / ATR 길이 (int ≥1, 기본 14)

ATR Mult for Stop / 손절 ATR 배수 (float ≥0.1, 기본 1.5)

ATR Mult for Take-Profit / 익절 ATR 배수 (float ≥0.1, 기본 2.0)

설명: 진입가 ± ATR×배수로 SL/TP 설정.

팁: 변동성 큰 자산은 SL 배수↑, TP 배수도 함께 조정 권장.

Use ATR Trailing Stop? / ATR 트레일링 사용 (bool, 기본 false)

ATR Mult for Trailing / 트레일링 ATR 배수 (float ≥0.1, 기본 2.0)

설명: 고정 TP/SL 대신 추적 손절을 사용(수익 추적에 유리).

E. 시각화 / Visualization

Plot 20MA / 20MA 표시 (bool, 기본 true)

Show Entry Markers / 진입 마커 표시 (bool, 기본 true)

4) 진입·청산 규칙 / Entry & Exit Rules

KR

진입: 위 “신호 로직” 충족 시 strategy.entry("L"/"S").

청산 (고정형):

롱: Stop = 진입 − ATR×SL, TP = 진입 + ATR×TP

숏: Stop = 진입 + ATR×SL, TP = 진입 − ATR×TP

청산 (트레일링형):

ATR×trailMult로 산출한 trail_points/offset으로 추적 손절.

EN

Entry: Place strategy.entry("L"/"S") when sync conditions are met.

Exit (Fixed):

Long: Stop = Entry − ATR×SL, TP = Entry + ATR×TP

Short: Stop = Entry + ATR×SL, TP = Entry − ATR×TP

Exit (Trailing):

Use ATR×trailMult as trailing distance & offset.

5) 알림 / Alerts

조건

Long Entry (Disp −Thr & Stoch Up, sync) → longSignal

Short Entry (Disp +Thr & Stoch Down, sync) → shortSignal

메시지 포맷 / Message format

{"signal":"long|short","symbol":"{{ticker}}","price":{{close}}}


Webhook(예: 거래소·봇)에서 signal/symbol/price를 활용해 체결 로직과 연동하십시오.

6) 빠른 시작 & 권장 프리셋 / Quick Start & Suggested Presets

KR — BTC/USDT (15분봉) 제안

maLen=20, thrPct=1.0~1.5, kLen=14, kS=1, dLen=3, stBuyLv=20, stSellLv=80

syncBars=1~3 (동시성 여유), useRelaxStoch=true, relaxLookback=5

고정형: atrLen=14, atrMultSL=1.5~2.0, atrMultTP=2.0~3.0

트레일링형: useTrail=true, trailMult=2.0~3.0

EN — BTC/USDT (15-min) suggestion

Above defaults, with syncBars=1~3, useRelaxStoch=true to improve fill realism.

Increase atrMultSL on high-volatility days to reduce whipsaws.

7) 운용 팁 & 점검 / Tips & Troubleshooting

KR

신호가 안 나와요: thrPct가 지나치게 크거나 syncBars=0으로 너무 엄격할 수 있음. thrPct↓, syncBars↑ 조정.

휩쏘 과다: useRelaxStoch를 끄거나 thrPct↑, atrMultSL↑.

TP 도달 전에 청산: 트레일링 사용 시 변동성 확대로 SL이 따라붙다 체결될 수 있음 → trailMult↑ 또는 고정형 전환.

과최적화 방지: 한 구간에 과특화된 튜닝(특히 syncBars, thrPct)은 다른 시장에서 성능 저하. Walk-forward 권장.

EN

No signals: Lower thrPct and/or increase syncBars.

Too many whipsaws: Disable relaxed mode, raise thrPct and/or atrMultSL.

Stopped before TP (trailing): Increase trailMult or switch to fixed exits.

Robustness: Avoid over-tuning; validate via walk-forward testing.

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.