
이 전략은 상대적으로 약한 지수 (RSI), 이동 평균의 종결 분산 지수 (MACD) 및 여러 다른 주기의 간단한 이동 평균 (SMA) 을 포함한 여러 기술적 지표를 결합하여 비트코인 (BTC) 거래에 대한 포괄적인 분석 도구를 제공하기 위해 고안되었습니다. 이 전략의 주요 아이디어는 다양한 지표의 신호를 종합적으로 고려하여 RSI가 특정 범위에있을 때 MACD가 나타나면 금 포크 가격이 여러 SMA보다 낮을 때 더 많이하고, 동시에 중지 손실과 중지 지점을 설정하고 RSI가 50에 도달하면 중지 손실 위치를 업데이트합니다.
이 전략은 RSI, MACD 및 SMA와 같은 기술 지표를 통합하여 비트코인 거래에 대한 포괄적인 분석 프레임워크를 제공합니다. 거래 신호를 생성하기 위해 여러 지표의 공동 인증을 사용하고 위험 제어 조치를 설정합니다. 그러나 전략에는 더 많은 지표, 동적 조정 파라미터 및 기본 분석과 같은 결합 된 전략의 최적화 공간이 있습니다. 실제 응용에서는 거래자는 자신의 위험 선호와 시장 환경에 따라 전략에 적절한 조정을해야합니다.
/*backtest
start: 2024-03-01 00:00:00
end: 2024-03-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Advanced Strategy", shorttitle="1M Advanced Strat", overlay=true)
// Input settings
rsiLength = input(14, title="RSI Length")
rsiLowerBound = input(20, title="RSI Lower Bound")
rsiUpperBound = input(30, title="RSI Upper Bound")
atrLength = input(14, title="ATR Length")
smaFastLength = input(20, title="SMA 20 Length")
smaMediumLength = input(50, title="SMA 50 Length")
smaSlowLength = input(200, title="SMA 200 Length")
riskPercent = input(0.005, title="Risk Percentage for SL and Target")
// Calculate indicators
rsiValue = rsi(close, rsiLength)
[macdLine, signalLine, _] = macd(close, 12, 26, 9)
smaFast = sma(close, smaFastLength)
smaMedium = sma(close, smaMediumLength)
smaSlow = sma(close, smaSlowLength)
atrValue = atr(atrLength)
// Checking previous RSI value
prevRsiValue = rsi(close[1], rsiLength)
// Conditions for Entry
longCondition = rsiValue > rsiLowerBound and rsiValue < rsiUpperBound and prevRsiValue < rsiLowerBound or prevRsiValue > rsiUpperBound and crossover(macdLine, signalLine) and close < smaFast and close < smaMedium and close < smaSlow
// Strategy Entry
if (longCondition and not strategy.position_size)
strategy.entry("Long", strategy.long)
// Setting Stop Loss and Take Profit
stopLoss = close - riskPercent * close
takeProfit = close + atrValue
strategy.exit("Exit Long", "Long", stop = stopLoss, limit = takeProfit)
//Update Stop Loss when RSI reaches 50
if (strategy.position_size > 0 and rsiValue >= 50)
strategy.exit("Update SL", "Long", stop = high)
// Conditions for Exit
shortCondition = crossunder(macdLine, signalLine)
// Strategy Exit
if (shortCondition)
strategy.close("Long")