Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

heloo

Syntax//@version=5
indicator("Advanced Strategy with RSI and MACD", overlay=true)

// Input parameters
smaLength = input.int(50, title="SMA Length")
rsiLength = input.int(14, title="RSI Length")
macdShort = input.int(12, title="MACD Short Length")
macdLong = input.int(26, title="MACD Long Length")
macdSignal = input.int(9, title="MACD Signal Length")

// Calculate indicators
sma = ta.sma(close, smaLength)
rsi = ta.rsi(close, rsiLength)
[macdLine, signalLine, _] = ta.macd(close, macdShort, macdLong, macdSignal)

// Plot indicators
plot(sma, title="SMA", color=color.blue)
hline(70, "Overbought", color=color.red)
hline(30, "Oversold", color=color.green)
is
// Entry condition: RSI < 30 and MACD line crosses above signal line
longCondition = (rsi < 30) and ta.crossover(macdLine, signalLine)
if (longCondition)
strategy.entry("Long", strategy.long)

// Exit condition: RSI > 70 or MACD line crosses below signal line
shortCondition = (rsi > 70) or ta.crossunder(macdLine, signalLine)
if (shortCondition)
strategy.close("Long")

You might also like