Chande Kroll Stop은 Tushar Chande와 Stanley Kroll이 개발한 추세 추종 지표로, ATR을 활용하여 변동성을 고려한 지지선과 저항선을 설정합니다. 일반적으로 단기 및 장기 지수 이동 평균(EMA)의 교차를 기반으로 계산되며, 가격이 지정된 스탑 레벨을 돌파하면 추세 반전 신호로 해석됩니다. 변동성이 높은 시장에서 트레일링 스탑(Trailing Stop)으로 유용하게 활용됩니다.
Chande Kroll Stop 구현
import pandas as pd
import ccxt
import pinetopy as pp
# Binance Futures, BTCUSDT, 1h
bnb = ccxt.binance({'options': { 'defaultType': 'future' }})
ohlcv = bnb.fetch_ohlcv(symbol="BTC/USDT", timeframe="1h", limit=500)
df = pd.DataFrame(ohlcv, columns=['time', 'open', 'high', 'low', 'close', 'volume'])
df['time'] = pp.kst(df['time'])
# TradingView Default Settings
def main(df, atr_length=10, ac=1, stop_length=9):
atr = pp.atr(df, atr_length)
first_hs = df['high'].rolling(atr_length).max() - ac * atr
first_ls = df['low'].rolling(atr_length).min() + ac * atr
df['stop_long'] = first_ls.rolling(stop_length).min()
df['stop_short'] = first_hs.rolling(stop_length).max()
return df[['time', 'stop_long', 'stop_short']]
print(main(df))
Check
트레이딩뷰 차트와 비교

