BITKUB:BTCTHB   비트코인 / 타이 바트
//@version=5
strategy("Custom Trading System - 4hr Chart", overlay=true, shorttitle="CTS")

// กำหนดค่าของสีและความหนาของเส้น
fastLength = input(12, title="Fast Length", minval=1)
slowLength = input(26, title="Slow Length", minval=1)
signalLength = input(9, title="Signal Length", minval=1)
rsiLength = input(14, title="RSI Length", minval=1)

// คำนวณ MACD
src = close
fastEMA = ema(src, fastLength)
slowEMA = ema(src, slowLength)
macdLine = fastEMA - slowEMA
signalLine = ema(macdLine, signalLength)

// คำนวณ RSI
rsiValue = rsi(close, rsiLength)

// สร้างสัญญาณการเข้าซื้อและขาย
longCondition = crossover(macdLine, signalLine) and close > sma(close, 50) and rsiValue < 30
shortCondition = crossunder(macdLine, signalLine) and close < sma(close, 50) and rsiValue > 70

// การจัดการตำแหน่ง
strategy.entry("Buy", strategy.long, when = longCondition)
strategy.entry("Sell", strategy.short, when = shortCondition)
strategy.close("Buy", when = crossunder(macdLine, signalLine) and close < sma(close, 50))
strategy.close("Sell", when = crossover(macdLine, signalLine) and close > sma(close, 50))
면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.