Pine Script (TradingView)
This is a TradingView Pine Script strategy example for this page concept. Paste it into the TradingView Pine Editor, add it to your chart, and run it in the Strategy Tester.
//@version=6
strategy("Carry Trade Strategy", overlay=true)
momLen = input.int(10, "Momentum Length")
trendLen = input.int(50, "Trend EMA")
rsiLen = input.int(14, "RSI Length")
mom = close - close[momLen]
ema50 = ta.ema(close, trendLen)
r = ta.rsi(close, rsiLen)
// Buy when momentum is positive, price above trend EMA, RSI not overbought
longSignal = mom > 0 and close > ema50 and r > 50 and r < 70
exitSignal = mom < 0 or close < ema50
if longSignal
strategy.entry("Mom", strategy.long)
if exitSignal
strategy.close("Mom")
plot(ema50, "Trend EMA", color=color.orange)