
이 전략은 지원, 저항, 그리고 트렌드 라인 세 가지 기술 지표를 사용하여 자동으로 입문 및 중지합니다. 전략은 먼저 중요한 지원 및 저항 지점을 식별하고 추세 방향과 결합하여 입문 시기를 판단합니다.
어떻게 대처해야 할까요?
이 전략은 여러 가지 기술 지표의 장점을 통합하여 합리적인 매개 변수 설정을 전제로 더 나은 수익 위험 비율을 얻을 수 있습니다. 매개 변수 설정을 최적화하고 출입 순서를 최적화하는 것이 중요합니다. 전체적으로 이 전략의 프레임 워크는 합리적이며 개선할 여지가 있습니다.
/*backtest
start: 2024-01-27 00:00:00
end: 2024-02-26 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Support Resistance Trend Strategy", overlay=true)
// Input parameters
supportLevel = input(100, title="Support Level")
resistanceLevel = input(200, title="Resistance Level")
riskRewardRatio = input(2, title="Risk-Reward Ratio")
trailStopLoss = input(true, title="Use Trailing Stop Loss")
// Calculate trend direction based on trend lines
trendUp = close > request.security(syminfo.tickerid, "D", close[1])
trendDown = close < request.security(syminfo.tickerid, "D", close[1])
// Buy signal condition
buySignal = close < supportLevel and trendUp
// Sell signal condition
sellSignal = close > resistanceLevel and trendDown
// Entry point and exit conditions
strategy.entry("Buy", strategy.long, when=buySignal)
strategy.entry("Sell", strategy.short, when=sellSignal)
// Calculate targets and stop-loss levels
targetPrice = close + (close - supportLevel) * riskRewardRatio
stopLossLevel = supportLevel
// Plot support and resistance levels
plot(supportLevel, color=color.green, linewidth=2, title="Support Level")
plot(resistanceLevel, color=color.red, linewidth=2, title="Resistance Level")
// Plot targets and stop-loss levels
plot(targetPrice, color=color.blue, linewidth=2, title="Target Price")
plot(stopLossLevel, color=color.orange, linewidth=2, title="Stop Loss Level")
// Trailing stop-loss
strategy.exit("Take Profit/Stop Loss", from_entry="Buy", loss=stopLossLevel, profit=targetPrice)
strategy.exit("Take Profit/Stop Loss", from_entry="Sell", loss=targetPrice, profit=stopLossLevel)
// Plot trail stop loss
if (trailStopLoss)
strategy.exit("Trailing Stop Loss", from_entry="Buy", loss=stopLossLevel)
strategy.exit("Trailing Stop Loss", from_entry="Sell", loss=stopLossLevel)