
Chiến lược này kết hợp nhiều chỉ số kỹ thuật, bao gồm chỉ số tương đối mạnh (RSI), chỉ số phân tán kết thúc đường trung bình di chuyển (MACD) và chỉ số di chuyển đơn giản (SMA) của một số chu kỳ khác nhau, nhằm cung cấp một công cụ phân tích toàn diện cho giao dịch Bitcoin (BTC). Ý tưởng chính của chiến lược này là thông qua việc xem xét tổng hợp các tín hiệu của các chỉ số khác nhau, thực hiện nhiều hơn khi RSI ở trong một phạm vi nhất định, MACD xuất hiện, giá Gold Forks thấp hơn nhiều SMA, đồng thời thiết lập lỗ dừng và dừng và cập nhật vị trí dừng khi RSI đạt 50.
Chiến lược này cung cấp một khung phân tích toàn diện cho giao dịch Bitcoin bằng cách sử dụng các chỉ số kỹ thuật như RSI, MACD và SMA. Nó sử dụng sự xác nhận chung của nhiều chỉ số để tạo ra tín hiệu giao dịch và đặt ra các biện pháp kiểm soát rủi ro. Tuy nhiên, chiến lược vẫn có không gian để tối ưu hóa, chẳng hạn như giới thiệu nhiều chỉ số hơn, tham số điều chỉnh động và kết hợp phân tích cơ bản.
/*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")