
이 전략은 트렌드 라인 브레이크를 기반으로 한 거래 시스템으로, 이동 평균과 가격의 브레이크 개념을 결합한다. 전략의 핵심은 거래 신호를 생성하기 위해 이동 평균의 브레이크를 감시하는 것과 최근 하위점과 2: 1 비율의 스톱을 기반으로 한 스톱을 설정하여 위험을 관리하는 것이다. 전략은 간단한 이동 평균을 트렌드 지표로 사용하여 가격과 평행 선의 교차로 트렌드 방향의 변화를 판단한다.
전략은 20주기의 간단한 이동 평균 ((SMA) 을 트렌드 지표로 사용한다. 종식 가격이 평균선 아래에서 상향으로 돌파될 때, 시스템은 여러 신호를 발생시킨다. 중단 지점은 지난 7개의 K선에서 가장 낮은 지점으로 설정되어, 이렇게 입구 지점과 너무 가깝게 피한다. 중단 지점의 설정은 클래식적인 2:1의 손실을 채택한다. 즉, 중단 거리는 중단 거리의 2배이다. 전략은 또한 시각적 구성 요소를 포함하고, 차트에 트렌드 라인을 표시한다. 거래 신호와 중단 지점.
이것은 구조적이고, 논리적으로 명확한 추세를 따라가는 전략이다. 이동 평균을 뚫고 신호를 생성하고, 합리적인 위험 관리 장치와 함께, 좋은 실용성을 가지고 있다. 일부 고유한 위험이 존재하지만, 제안된 최적화 방향은 전략의 안정성과 수익성을 더욱 향상시킬 수 있다. 전략은 추세가 뚜렷한 시장 환경에서 사용하기에 적합하며, 거래자는 특정 시장 특성에 따라 파라미터 설정을 조정할 수 있다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-11 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Trend Breakout with SL and TP", overlay=true)
// Parametrlar
length = input(25, title="Length for SL Calculation")
trendLength = input(20, title="Trend Line Length")
// Trend chizig'ini hisoblash
trendLine = ta.sma(close, trendLength)
// Yopilish narxi trend chizig'ini yorib o'tganda signal
longSignal = close > trendLine and close[1] <= trendLine
// Oxirgi 7 shamning minimumini hisoblash
lowestLow = ta.lowest(low, 7)
// Stop Loss darajasini belgilash
longSL = lowestLow // SL oxirgi 7 shamning minimumiga teng
// Take Profit darajasini SL ga nisbatan 2 baravar ko'p qilib belgilash
longTP = longSL + (close - longSL) * 2 // TP 2:1 nisbatida
// Savdo bajarish
if longSignal
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit", "Long", limit=longTP)
strategy.exit("Stop Loss", "Long", stop=longSL)
// Grafikda trend chizig'ini chizish
plot(trendLine, title="Trend Line", color=color.blue, linewidth=2)
// Signal chizish
plotshape(longSignal, style=shape.labelup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
// SL va TP darajalarini ko'rsatish
// if longSignal
// // SL chizig'i
// line.new(bar_index, longSL, bar_index + 1, longSL, color=color.red, width=2, style=line.style_dashed)
// // TP chizig'i
// line.new(bar_index, longTP, bar_index + 1, longTP, color=color.green, width=2, style=line.style_dashed)
// // SL va TP label'larini ko'rsatish
// label.new(bar_index, longSL, "SL: " + str.tostring(longSL), color=color.red, style=label.style_label_down, textcolor=color.white, size=size.small)
// label.new(bar_index, longTP, "TP: " + str.tostring(longTP), color=color.green, style=label.style_label_up, textcolor=color.white, size=size.small)