BITKUB:BTCTHB   Bitcoin / Baht Thai
//@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))
Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.