
이 전략은 ATR ((평균 실제 파도) 지표에 기반한 동적 추적 중지 전략이다. ATR 값을 통해 동적으로 중지 위치를 조정하고 EMA 평준과 결합하여 거래 신호를 확인한다. 전략은 유연한 포지션 관리를 지원하며, 다른 시장 환경과 거래 품종에 따라 주문 구매 판매 수를 할 수 있다.
전략의 핵심 논리는 다음과 같은 핵심 요소에 기초합니다.
이 전략은 ATR 지표와 EMA 평행선을 결합하여 신뢰할 수 있는 동적 추적 스톱 손실 시스템을 구축한다. 그것의 장점은 시장의 변동에 적응할 수 있고, 완벽한 위험 관리 메커니즘을 가지고 있으며, 동시에 동작의 유연성을 유지한다는 것이다. 일부 고유한 위험이 존재하지만, 지속적인 최적화 및 개선으로, 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 수 있을 것으로 보인다. 거래자는 실장 사용 전에 여러 가지 요소 조합을 충분히 테스트하고, 특정 거래 품종의 특성에 따라 타깃적 최적화를 수행하는 것이 좋습니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title='ADET GİRMELİ Trend İz Süren Stop Strategy', overlay=true, overlay=true,default_qty_type = strategy.fixed, default_qty_value = 1)
// Inputs
a = input(9, title='Key Value. "This changes the sensitivity"')
c = input(3, title='ATR Period')
h = input(false, title='Signals from Heikin Ashi Candles')
xATR = ta.atr(c)
nLoss = a * xATR
src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close
xATRTrailingStop = 0.0
iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2
pos = 0
iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(src, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
// Alım ve Satım Sinyalleri
buySignal = src > xATRTrailingStop and above
sellSignal = src < xATRTrailingStop and below
// Kullanıcı girişi
sell_quantity = input.int(1, title="Sell Quantity", minval=1)
buy_quantity = input.int(1, title="Buy Quantity", minval=1)
// Portföy miktarı (örnek simülasyon verisi)
var portfolio_quantity = 0
// Sinyal üretimi (örnek sinyal, gerçek stratejinizle değiştirin)
indicator_signal = (src > xATRTrailingStop and above) ? "buy" :
(src < xATRTrailingStop and below) ? "sell" : "hold"
// Şartlara göre al/sat
if indicator_signal == "buy" and portfolio_quantity < buy_quantity
strategy.entry("Buy Order", strategy.long, qty=buy_quantity)
portfolio_quantity := portfolio_quantity + buy_quantity
if indicator_signal == "sell" and portfolio_quantity >= sell_quantity
strategy.close("Buy Order", qty=sell_quantity)
portfolio_quantity := portfolio_quantity - sell_quantity
// Plot buy and sell signals
plotshape(buy, title='Buy', text='Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(sell, title='Sell', text='Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)
// Bar coloring
barcolor(barbuy ? color.rgb(6, 250, 14) : na)
barcolor(barsell ? color.red : na)
// Alerts
alertcondition(buy, 'UT Long', 'UT Long')
alertcondition(sell, 'UT Short', 'UT Short')
// Strategy Entry and Exit
if buy
strategy.entry('Long', strategy.long)
if sell
strategy.entry('Short', strategy.short)
// Optional Exit Conditions
if sell
strategy.close('Long')
if buy
strategy.close('Short')