//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))
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))
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.