code-dumps/tradingview/macd-rsi.txt

32 lines
813 B
Plaintext
Raw Normal View History

2024-10-24 23:09:21 +08:00
//@version=2
strategy("MACD-L RSI-S Strategy", overlay=true)
// Buy when MACD crossover upwards
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)
MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD
if (crossover(delta, 0))
strategy.entry("MacdCU", strategy.long, comment="MacdCU")
// Sell when RSI exceeds 75
length = input( 14 )
overSold = input( 30 )
overBought = input( 75 )
price = close
vrsi = rsi(price, length)
co = crossover(vrsi, overSold)
cu = crossunder(vrsi, overBought)
if (not na(vrsi))
if (cu)
strategy.entry("RsiSE", strategy.short, comment="RsiSE")
// strategy.close_all(comment = "RsiSE")
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)