OPEN-SOURCE SCRIPT

Rolling Highest + Qualified Ghost (price-synced)[돌파]

56
English Guide
What this indicator does

Plots a rolling highest line hh = ta.highest(src, len) that step-changes whenever the highest value inside the last len bars changes.

When a step ends after being flat for at least minHold bars (a “plateau”), it draws a short horizontal ghost line for ghostLen bars to the right at the previous step level.

By default, the ghost appears only on step-down events (behaves like a short-lived resistance trace). You can allow both directions with the onlyOnDrop setting.

Everything is rendered with plot() series (not drawing objects), bound to the right price scale → it moves perfectly with the chart.

Inputs

len — Lookback window (bars) for the rolling highest.

basis — Price basis used to compute the highest: High / Close / HLC3 / OHLC4.

minHold — Minimum plateau length (bars). Only steps that stayed flat at least this long qualify for a ghost.

ghostLen — Number of bars to keep the horizontal ghost to the right.

onlyOnDrop — If true, make ghosts only when the step moves down (default). If false, also create ghosts on step-ups.

Visuals: mainColor/mainWidth for the main rolling highest line; ghostColor/ghostTrans/ghostWidth for the ghost.

How it works (logic)

Rolling highest:
hh = ta.highest(src, len) produces a stair-like line.

Step detection:

stepUp = hh > hh[1]

stepDown = hh < hh[1]

startUp / startDown mark the first bar of a new step (prevents retriggering while the step continues).

Plateau length (runLen):
Counts consecutive bars where hh remained equal:
runLen := (hh == hh[1]) ? runLen[1] + 1 : 1

Qualification:
On the first bar of a step change, check previous plateau length prevHold = runLen[1].
If prevHold ≥ minHold and direction matches onlyOnDrop, start a ghost:

ghostVal := hh[1] (the previous level)

ghostLeft := ghostLen

Ghost series:
While ghostLeft > 0, output ghostVal; otherwise output na.
It’s plotted with plot.style_linebr so the line appears as short, clean horizontal segments instead of connecting across gaps.

Why it stays synced to price

The indicator uses overlay=true, scale=scale.right, format=format.price, and pure series plot().
No line.new() objects → no “stuck on screen” behavior when panning/zooming.

Tips & customization

If your chart is a line chart (close), set basis = Close so visuals align perfectly.

Want ghosts on both directions? Turn off onlyOnDrop.

Make ghosts subtler by increasing ghostTrans (e.g., 60–80).

If ghosts appear too often or too rarely, tune minHold and len.
Larger minHold = only long, meaningful plateaus will create ghosts.

Edge cases

If len is very small or the market is very volatile, plateaus may be rare → fewer ghosts.

If the stair level changes almost every few bars, raise len or minHold.

한글 설명서
기능 요약

최근 len개 바 기준의 롤링 최고가 hh를 그립니다. 값이 바뀔 때마다 계단식(step)으로 변합니다.

어떤 계단이 최소 minHold봉 이상 유지된 뒤 스텝이 끝나면, 직전 레벨을 기준으로 우측 ghostLen봉짜리 수평선(고스트) 을 그립니다.

기본값은 하락 스텝에서만 고스트를 생성(onlyOnDrop=true). 꺼두면 상승 스텝에서도 만듭니다.

전부 plot() 시리즈 기반 + 우측 가격 스케일 고정 → 차트와 완전히 동기화됩니다.

입력값

len — 롤링 최고가 계산 윈도우(바 수).

basis — 최고가 계산에 사용할 기준: High / Close / HLC3 / OHLC4.

minHold — 플래토(같은 값 유지) 최소 길이. 이 이상 유지된 스텝만 고스트 대상.

ghostLen — 우측으로 고스트를 유지할 바 수.

onlyOnDrop — 체크 시 하락 스텝에서만 고스트 생성(기본). 해제하면 상승 스텝도 생성.

표시 옵션: 본선(mainColor/mainWidth), 고스트(ghostColor/ghostTrans/ghostWidth).

동작 원리

롤링 최고가:
hh = ta.highest(src, len) → 계단형 라인.

스텝 변화 감지:

stepUp = hh > hh[1], stepDown = hh < hh[1]

startUp / startDown 으로 첫 바만 잡아 중복 트리거 방지.

플래토 길이(runLen):
hh가 같은 값으로 연속된 길이를 누적:
runLen := (hh == hh[1]) ? runLen[1] + 1 : 1

자격 판정:
스텝이 바뀌는 첫 바에서 직전 플래토 길이 prevHold = runLen[1]가 minHold 이상이고, 방향이 설정(onlyOnDrop)과 맞으면 고스트 시작:

ghostVal := hh[1] (직전 레벨)

ghostLeft := ghostLen

고스트 출력:
ghostLeft > 0 동안 ghostVal을 출력, 아니면 na.
plot.style_linebr로 짧은 수평 구간만 보이게 합니다(NA 구간에서 선을 끊음).

가격과 동기화되는 이유

overlay=true, scale=scale.right, format=format.price로 가격 스케일에 고정, 그리고 모두 plot() 시리즈로 그립니다.
line.new() 같은 도형 객체를 쓰지 않아 스크롤/줌 시 화면에 박히는 현상이 없습니다.

활용 팁

차트를 라인(종가) 로 보신다면 basis = Close로 맞추면 시각적으로 더욱 정확히 겹칩니다.

고스트가 너무 자주 나오면 minHold를 올리거나 len을 키워서 스텝 빈도를 낮추세요.

고스트를 더 은은하게: ghostTrans 값을 크게(예: 60–80).

저항/지지 라인처럼 보이게 하려면 기본 설정(onlyOnDrop=true)이 잘 맞습니다.

주의할 점

변동성이 큰 종목/타임프레임에선 플래토가 짧아 고스트가 드물 수 있습니다.

len이 너무 작으면 스텝이 잦아져 노이즈가 늘 수 있습니다.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.