// สร้างสัญญาณการเข้าซื้อและขาย 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))