Scalping

Scalping

//@version=5
strategy("Scalping Strategy", overlay=true)

// Input parameters
short_ma_length = input.int(9, title="Short MA Length")
long_ma_length = input.int(21, title="Long MA Length")
rsi_length = input.int(14, title="RSI Length")
rsi_overbought = input.int(70, title="RSI Overbought Level")
rsi_oversold = input.int(30, title="RSI Oversold Level")

// Calculate indicators
short_ma = ta.sma(close, short_ma_length)
long_ma = ta.sma(close, long_ma_length)
rsi = ta.rsi(close, rsi_length)

// Entry conditions
buy_condition = ta.crossover(short_ma, long_ma) and rsi < rsi_oversold
sell_condition = ta.crossunder(short_ma, long_ma) and rsi > rsi_overbought

// Execute orders
if (buy_condition)
strategy.entry("Buy", strategy.long)

if (sell_condition)
strategy.entry("Sell", strategy.short)

// Plot indicators
plot(short_ma, color=color.blue, title="Short MA")
plot(long_ma, color=color.red, title="Long MA")
hline(rsi_overbought, "Overbought", color=color.red)
hline(rsi_oversold, "Oversold", color=color.green)
plot(rsi, color=color.purple, title="RSI")

Read More

Share:

Latest News