
이 전략은 MACD, ADX 및 EMA200 지표를 기반으로 현재 시장의 추세와 동력을 판단하여 여러 시간 프레임에 따라 트렌드 거래를 수행합니다. 전략의 주요 아이디어는 MACD 지표를 사용하여 시장의 추세를 판단하고, ADX 지표는 트렌드 강도를 확인하며, EMA200은 트렌드 필터 조건으로 동시에 여러 시간 프레임을 사용하여 거래 기회를 더 많이 얻고 더 나은 수익 위험 비율을 얻습니다.
해결책:
이러한 최적화를 통해 전략의 융통성과 수익성을 높이고, 다양한 시장 환경에 더 잘 적응할 수 있다.
이 전략은 MACD, ADX 및 EMA200와 같은 지표들을 결합하여 여러 시간 프레임에 따라 트렌드 거래를 수행함으로써 특정 장점과 가용성을 가지고 있습니다. 전략의 핵심은 트렌드 판단과 트렌드 강도를 확인하는 데 있습니다. 여러 지표의 공동 작용을 통해 트렌드 기회를 더 잘 잡을 수 있습니다. 동시에, 전략은 고정된 스톱 스톱을 사용하여 위험을 제어하는 데 도움이됩니다.
/*backtest
start: 2024-02-01 00:00:00
end: 2024-02-29 23:59:59
period: 1h
basePeriod: 15m
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/
// © colemanrumsey
//@version=5
strategy("15-Minute Trend Trading Strategy", overlay=true)
// Exponential Moving Average (EMA)
ema200 = ta.ema(close, 200)
// MACD Indicator
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
macdHistogram = macdLine - signalLine
// Calculate True Range (TR)
tr = ta.tr
// Calculate +DI and -DI
plusDM = high - high[1]
minusDM = low[1] - low
atr14 = ta.atr(14)
plusDI = ta.wma(100 * ta.sma(plusDM, 14) / atr14, 14)
minusDI = ta.wma(100 * ta.sma(minusDM, 14) / atr14, 14)
// Calculate Directional Movement Index (DX)
dx = ta.wma(100 * math.abs(plusDI - minusDI) / (plusDI + minusDI), 14)
// Calculate ADX
adxValue = ta.wma(dx, 14)
// Long Entry Condition
longCondition = close > ema200 and (macdLine > signalLine) and (macdLine < 0) and (adxValue >= 25)
// Short Entry Condition
shortCondition = close < ema200 and (macdLine < signalLine) and (macdLine > 0) and (adxValue >= 25)
// Calculate ATR for Stop Loss
atrValue = ta.atr(14)
// Initialize Take Profit and Stop Loss
var float takeProfit = na
var float stopLoss = na
// Calculate Risk (Stop Loss Distance)
risk = close - low[1] // Using the previous candle's low as stop loss reference
// Strategy Orders
if longCondition
stopLoss := close * 0.99 // Set Stop Loss 1% below the entry price
takeProfit := close * 1.015 // Set Take Profit 1.5% above the entry price
strategy.entry("Buy", strategy.long, stop=stopLoss, limit=takeProfit)
if shortCondition
stopLoss := close * 1.01 // Set Stop Loss 1% above the entry price
takeProfit := close * 0.985 // Set Take Profit 1.5% below the entry price
strategy.entry("Sell", strategy.short, stop=stopLoss, limit=takeProfit)
// Plot EMA
// plot(ema200, color=color.blue, linewidth=1, title="200 EMA")
// Plot MACD Histogram
// plot(macdHistogram, color=macdHistogram > 0 ? color.green : color.red, style=plot.style_columns, title="MACD Histogram")
// Display ADX Value
// plot(adxValue, color=color.purple, title="ADX Value")