
이것은 평균 트렌드 지표 ((ADX) 와 가격 돌파구를 기반으로 한 양적 거래 전략이다. 이 전략은 주로 ADX 지표 수치를 모니터링하여 시장 트렌드 강도를 판단하고, 가격 돌파구 신호와 결합하여 시장 동력을 포착한다. 이 전략은 특정 거래 시간 내에 작동하도록 설정되어 있으며, 중지 손실과 매일 거래 횟수 제한을 통해 위험 관리를 수행한다.
전략의 핵심 논리에는 다음과 같은 핵심 요소가 포함됩니다.
이것은 구조적이고 논리적으로 명확한 트렌드 추적 전략이다. ADX 지표와 가격 돌파구를 결합하여 효과적인 위험 관리 프레임 워크 아래에서 시장 트렌드 기회를 포착한다. 일부 최적화 공간이 있지만 전략의 기본 프레임 워크는 양적 거래 시스템의 기본 구성 요소로 적합하며 전략의 기본 프레임 워크는 견고하다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HuntGatherTrade
// ========================
// NQ 30 minute, ES 30 minute
//@version=5
strategy("ADX Breakout", overlay=false, initial_capital=25000, default_qty_value=1)
// ===============================
// Input parameters
// ===============================
stopLoss = input(1000.0, title="Stop Loss ($)", group="Exits")
session = input("0730-1430:1234567", group="Trade Session")
highestLB = input(34, title="Highest lookback window", group="Indicator values")
// ===============================
// Trade Session Handling
// ===============================
t = time(timeframe.period, session)
// Reset numTrades at the start of each session
var int numTrades = 0
is_new_session = ta.change(time("D")) != 0
if is_new_session
numTrades := 0
// ===============================
// Entry Conditions
// ===============================
[plusDI, minusDI, adxValue] = ta.dmi(50, 14)
entryCondition = (close >= ta.highest(close, highestLB)[1]) and (adxValue < 17.5) and (strategy.position_size == 0) and (numTrades < 3) and not na(t)
// ===============================
// 7. Execute Entry
// ===============================
var float stopPricePlot = na
if entryCondition
entryPrice = close + syminfo.mintick
strategy.entry("Long Entry", strategy.long, stop=entryPrice)
//stopPrice = strategy.position_avg_price - (stopLoss / syminfo.pointvalue)
//strategy.exit("Stop Loss", "Long Entry", stop=stopPrice)
numTrades += 1
if (strategy.position_size > 0) and (strategy.position_size[1] == 0)
stopPoints = stopLoss / syminfo.pointvalue
stopPrice = strategy.position_avg_price - stopPoints
stopPrice := math.round(stopPrice / syminfo.mintick) * syminfo.mintick
strategy.exit("Stop Loss", from_entry="Long Entry", stop=stopPrice)
if ta.change(strategy.opentrades) == 1
float entryPrice = strategy.opentrades.entry_price(0)
stopPricePlot := entryPrice - (stopLoss / syminfo.pointvalue)
if ta.change(strategy.closedtrades) == 1
stopPricePlot := na
plot(stopPricePlot, "Stop-loss level", color.red, 1, plot.style_linebr)
// ===============================
// Exit at End of Session
// ===============================
if na(t) and strategy.position_size != 0
strategy.close_all(comment="End of Day Exit")