OPEN-SOURCE SCRIPT

Crypto and Stock Buy/Sell Signals

//version=5
indicator("Crypto and Stock Buy/Sell Signals", overlay=true)

// Parameters for Moving Averages
short_ma_length = input.int(50, title="Short Moving Average Length")
long_ma_length = input.int(200, title="Long Moving Average Length")

// Parameters for RSI
rsi_length = input.int(14, title="RSI Length")
upper_rsi = input.int(70, title="Overbought Level (Sell)")
lower_rsi = input.int(30, title="Oversold Level (Buy)")

// Parameters for Bollinger Bands
bb_length = input.int(20, title="Bollinger Bands Length")
bb_mult = input.float(2.0, title="Bollinger Bands Multiplier")

// Calculating Moving Averages
short_ma = ta.sma(close, short_ma_length)
long_ma = ta.sma(close, long_ma_length)

// Calculating RSI
rsi = ta.rsi(close, rsi_length)

// Calculating MACD
[macd_line, signal_line, _] = ta.macd(close, 12, 26, 9)

// Calculating Bollinger Bands
bb_basis = ta.sma(close, bb_length)
bb_dev = bb_mult * ta.stdev(close, bb_length)
bb_upper = bb_basis + bb_dev
bb_lower = bb_basis - bb_dev

// Relaxed Buy/Sell Signal Conditions
buy_signal = ta.crossover(short_ma, long_ma) or (rsi < lower_rsi) or ta.crossover(macd_line, signal_line) or (close < bb_lower)
sell_signal = ta.crossunder(short_ma, long_ma) or (rsi > upper_rsi) or ta.crossunder(macd_line, signal_line) or (close > bb_upper)

// Confirmed Buy/Sell Signals (More Specific)
volume_sma = ta.sma(volume, 20)
confirmed_buy_signal = buy_signal and (volume > volume_sma) // Adding volume confirmation for stronger buy signal
confirmed_sell_signal = sell_signal and (volume > volume_sma) // Adding volume confirmation for stronger sell signal

// Plotting Buy/Sell Signals
plotshape(confirmed_buy_signal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(confirmed_sell_signal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)

// Plotting Moving Averages
plot(short_ma, title="Short Moving Average", color=color.blue, linewidth=2)
plot(long_ma, title="Long Moving Average", color=color.orange, linewidth=2)

// Plotting Bollinger Bands
plot(bb_upper, title="Bollinger Upper Band", color=color.purple, linewidth=1)
plot(bb_lower, title="Bollinger Lower Band", color=color.purple, linewidth=1)

// Background Color for Overbought/Oversold RSI
bgcolor(rsi > upper_rsi ? color.new(color.red, 90) : na, title="Overbought Background")
bgcolor(rsi < lower_rsi ? color.new(color.green, 90) : na, title="Oversold Background")
Candlestick analysisChart patternseducational

Script de código abierto

Siguiendo fielmente el espíritu de TradingView, el autor de este script lo ha publicado en código abierto, permitiendo que otros traders puedan entenderlo y verificarlo. ¡Olé por el autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la reutilización de este código en la publicación se rige por las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

¿Quiere utilizar este script en un gráfico?

Exención de responsabilidad