OPEN-SOURCE SCRIPT

Stoch RSI & RSI Buy/Sell Signals with MACD Trend Filter

已更新
This indicator combines multiple technical analysis tools and conditions to generate precise buy and sell signals. It utilizes the Stochastic RSI and RSI for overbought/oversold signals, a MACD trend filter, and candle color confirmation to avoid false signals. Key conditions include:

Buy Signal:
Conditions Met on Previous Candle:
  • Stochastic RSI (%K) is below the user-defined oversold level.
  • RSI is either below the neutral level or within the oversold range.
  • MACD line is in a bearish trend, confirmed by three consecutive downward bars.
  • Current Candle Requirement: Closes in green to confirm a buy.


Sell Signal:
Conditions Met on Previous Candle:
  • Stochastic RSI (%K) is above the user-defined overbought level.
  • RSI is either above the neutral level or within the overbought range.
  • MACD line is in a bullish trend, confirmed by three consecutive upward bars.
  • Current Candle Requirement: Closes in red to confirm a sell.


This indicator also includes custom color settings based on RSI levels and can be toggled to display buy/sell signals visually on the chart.
-------
DONATIONS:
USDT: 0x678d7ca85574f35c4ad7c673c92cd3f4795f98d9 (ERC20)
發布通知
// Track previous RSI value
var float previousRsiValue = na

// Update flags if conditions are met
if (buyConditionMet)
buyFlag := true
previousRsiValue := rsi // Store the RSI value for the label

if (sellConditionMet)
sellFlag := true
previousRsiValue := rsi // Store the RSI value for the label

// Determine colors for buy/sell signals based on RSI level
buyColor = (previousRsiValue < 35) ? buyColorGreen : buyColorBlue // Use user-defined green if RSI <= 35, else blue
sellColor = (previousRsiValue > 65) ? sellColorRed : sellColorOrange // Use user-defined red if RSI >= 70, else orange

// Signals with flag and candle color checks
buySignal = buyFlag and close > open
sellSignal = sellFlag and close < open

// Reset flags after signals are triggered
if (buySignal)
buyFlag := false
if (sellSignal)
sellFlag := false

// Alerts
alertcondition(buySignal, title="Buy Alert", message="Buy signal generated!")
alertcondition(sellSignal, title="Sell Alert", message="Sell signal generated!")

// User input to toggle buy/sell signals visibility
showSignals = input(true, title="Show Buy/Sell Signals")

// Plotting buy/sell signals based on user input with previous RSI value in the text
if (showSignals and buySignal)
label.new(bar_index, low, "BUY (" + str.tostring(math.floor(previousRsiValue)) + ")", color=buyColor, style=label.style_label_up, textcolor=color.white, size=size.small)

if (showSignals and sellSignal)
label.new(bar_index, high, "SELL (" + str.tostring(math.floor(previousRsiValue)) + ")", color=sellColor, style=label.style_label_down, textcolor=color.white, size=size.small)
發布通知
- Fixed some issues related to the color of the signals.
發布通知
- In this update, all conditions were added to the settings so each one of them can be enabled/disabled
buysellsignalforecastingRelative Strength Index (RSI)Stochastic RSI (STOCH RSI)strategiestrategy

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?

免責聲明