커뮤니티

Chandelier Exit 코딩을 부탁드립니다.

프로필 이미지
jhs0713
2025-11-20 15:05:41
56
글번호 228262
답변완료

//@version=6
// Copyright (c) 2019-present, Alex Orekhov (everget) // Chandelier Exit script may be freely distributed under the terms of the GPL-3.0 license. indicator('Chandelier Exit', shorttitle = 'CE', overlay = true)
const string calcGroup = 'Calculation' length = input.int(22, title = 'ATR Period', group = calcGroup) mult = input.float(3.0, step = 0.1, title = 'ATR Multiplier', group = calcGroup) useClose = input.bool(true, title = 'Use Close Price for Extremums', group = calcGroup)
const string visualGroup = 'Visuals' showLabels = input.bool(true, title = 'Show Buy/Sell Labels', group = visualGroup) highlightState = input.bool(true, title = 'Highlight State', group = visualGroup)
const string alertGroup = 'Alerts' awaitBarConfirmation = input.bool(true, title = 'Await Bar Confirmation', group = alertGroup)
//---
atr = mult * ta.atr(length)
longStop = (useClose ? ta.highest(close, length) : ta.highest(length)) - atr longStopPrev = nz(longStop[1], longStop) longStop := close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop
shortStop = (useClose ? ta.lowest(close, length) : ta.lowest(length)) + atr shortStopPrev = nz(shortStop[1], shortStop) shortStop := close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
var int dir = 1 dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir
const color textColor = color.white const color longColor = color.green const color shortColor = color.red const color longFillColor = color.new(color.green, 85) const color shortFillColor = color.new(color.red, 85)
buySignal = dir == 1 and dir[1] == -1 longStopPlot = plot(dir == 1 ? longStop : na, title = 'Long Stop', style = plot.style_linebr, linewidth = 2, color = longColor) plotshape(buySignal ? longStop : na, title = 'Long Stop Start', location = location.absolute, style = shape.circle, size = size.tiny, color = longColor) plotshape(buySignal and showLabels ? longStop : na, title = 'Buy Label', text = 'Buy', location = location.absolute, style = shape.labelup, size = size.tiny, color = longColor, textcolor = textColor)
sellSignal = dir == -1 and dir[1] == 1 shortStopPlot = plot(dir == 1 ? na : shortStop, title = 'Short Stop', style = plot.style_linebr, linewidth = 2, color = shortColor) plotshape(sellSignal ? shortStop : na, title = 'Short Stop Start', location = location.absolute, style = shape.circle, size = size.tiny, color = shortColor) plotshape(sellSignal and showLabels ? shortStop : na, title = 'Sell Label', text = 'Sell', location = location.absolute, style = shape.labeldown, size = size.tiny, color = shortColor, textcolor = textColor)
midPricePlot = plot(ohlc4, title = '', display = display.none, editable = false)
fill(midPricePlot, longStopPlot, title = 'Long State Filling', color = (highlightState and dir == 1 ? longFillColor : na)) fill(midPricePlot, shortStopPlot, title = 'Short State Filling', color = (highlightState and dir == -1 ? shortFillColor : na))
await = awaitBarConfirmation ? barstate.isconfirmed : true alertcondition(dir != dir[1] and await, title = 'CE Direction Change', message = 'Chandelier Exit has changed direction, {{exchange}}:{{ticker}}') alertcondition(buySignal and await, title = 'CE Buy', message = 'Chandelier Exit Buy, {{exchange}}:{{ticker}}') alertcondition(sellSignal and await, title = 'CE Sell', message = 'Chandelier Exit Sell, {{exchange}}:{{ticker}}')

지표
답변 3
프로필 이미지

예스스탁 예스스탁 답변

2025-11-20 15:53:50

안녕하세요 예스스탁입니다. input : length(22); input : mult(3.0); input : useClose(1);#1:종가, 0:고가/저가 var : alpha(0),atrv(0),a(0); var : longStop(0),longStopPrev(0),shortStop(0),shortStopPrev(0),dir(1); var : Buysignal(False),Sellsignal(False),tx(0); alpha = 1 / length ; atrv = IFf(IsNan(ATRV[1]) == true, ma(TrueRange,length) , alpha * TrueRange + (1 - alpha) * IFf(isnan(ATRV[1])==true,0,ATRV[1])); a = mult * atrv; longStop = IFF(useClose == 1,highest(close, length), highest(H,length)) - a; longStopPrev = iff(isnan(longStop[1])==true, longStop,longStop[1]); longStop = iff(close[1] > longStopPrev , max(longStop, longStopPrev) , longStop); shortStop = IFF(useClose == 1,lowest(close, length), lowest(L,length)) + a; shortStopPrev = iff(IsNan(shortStop[1])==true, shortStop[1], shortStop); shortStop = iff(close[1] < shortStopPrev , min(shortStop, shortStopPrev) , shortStop); dir = iff(close > shortStopPrev , 1 , iff(close < longStopPrev , -1 , dir)); buySignal = dir == 1 and dir[1] == -1; sellSignal = dir == -1 and dir[1] == 1; if dir == 1 Then { Plot1(longStop,"LongStop",Green); NoPlot(2); } else { NoPlot(1); Plot2(shortStop,"ShortStop",Red); } if buySignal == true then { tx = Text_New(sDate,sTime,longStop,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Green); } if SellSignal == true then { tx = Text_New(sDate,sTime,shortStop,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Red); } 즐거운 하루되세요
프로필 이미지

jhs0713

2025-11-20 17:23:57

감사합니다~~
프로필 이미지

ksks

2025-11-21 10:44:17

답변2는 지표수식 아닌가요?

그렇다면 chandelier exit을 검색하는 종목검색 수식이 가능할까요?
예를들면 60분봉에서.