BITKUB:BTCTHB   Bitcoin/Thailändska baht
//@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))
Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.