
이 전략은 무작위 지표 (Stochastic Oscillator) 에 기반한 다시간 프레임波段 거래 시스템이다. 현재 시간 프레임과 더 높은 시간 프레임의 무작위 지표 신호를 결합하여 거래 기회를 결정하고, 동적 스톱 로즈를 사용하여 위험을 관리한다. 이 전략은 변동성이 높은 시장에 적용되며, 가격의 단기 변동을 포착하여 수익을 얻는다.
전략의 핵심 논리는 다음과 같은 핵심 요소에 기초합니다.
이것은 기술 분석과 위험 관리를 결합한 완전한 거래 시스템이다. 다중 시간 프레임의 신호 확인과 동적 중지 중지으로, 전략은 안정성을 보장하면서도 좋은 수익 잠재력을 가지고 있다. 그러나 사용자는 자신의 거래 스타일과 시장 환경에 따라 파라미터를 최적화하고 항상 엄격한 위험 통제를 유지해야합니다.
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Swing Fairas Oil", overlay=true)
// Input parameters
kLength = input(14, title="Stochastic K Length")
dLength = input(3, title="Stochastic D Length")
smoothK = input(3, title="Smooth K")
tfHigher = input.timeframe("30", title="Higher Timeframe")
takeProfit = input(1.7, title="Take Profit Multiplier")
stopLoss = input(1.7, title="Stop Loss Multiplier")
// Calculate Stochastic Oscillator for current timeframe
k = ta.sma(ta.stoch(close, high, low, kLength), smoothK)
d = ta.sma(k, dLength)
// Calculate Stochastic Oscillator for higher timeframe
kHTF = request.security(syminfo.tickerid, tfHigher, ta.sma(ta.stoch(close, high, low, kLength), smoothK))
dHTF = request.security(syminfo.tickerid, tfHigher, ta.sma(kHTF, dLength))
// Buy and sell conditions (confirmation from two timeframes)
buyCondition = ta.crossover(k, d) and k < 20 and kHTF < 20 and kHTF > dHTF
sellCondition = ta.crossunder(k, d) and k > 80 and kHTF > 80 and kHTF < dHTF
// Define Take Profit and Stop Loss levels
longStopLoss = close * (1 - stopLoss / 100)
longTakeProfit = close * (1 + takeProfit / 100)
shortStopLoss = close * (1 + stopLoss / 100)
shortTakeProfit = close * (1 - takeProfit / 100)
// Execute Trades
if buyCondition
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", from_entry="Long", limit=longTakeProfit, stop=longStopLoss)
if sellCondition
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", from_entry="Short", limit=shortTakeProfit, stop=shortStopLoss)
// Plot buy/sell signals on candlestick chart
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, size=size.small, title="Buy Signal")
plotshape(series=sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, size=size.small, title="Sell Signal")
// Highlight candles for buy and sell conditions
barcolor(buyCondition ? color.green : sellCondition ? color.red : na)
// Draw Take Profit and Stop Loss levels dynamically with labels
var float tpLevel = na
var float slLevel = na
if buyCondition
tpLevel := longTakeProfit
slLevel := longStopLoss
if sellCondition
tpLevel := shortTakeProfit
slLevel := shortStopLoss