OPEN-SOURCE SCRIPT

High-Accuracy Buy/Sell Signal

//version=5
indicator("High-Accuracy Buy/Sell Signal", overlay=true)

// Input parameters
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")

macdFastLength = input.int(12, title="MACD Fast Length")
macdSlowLength = input.int(26, title="MACD Slow Length")
macdSignalSmoothing = input.int(9, title="MACD Signal Smoothing")

bbLength = input.int(20, title="Bollinger Bands Length")
bbMultiplier = input.float(2.0, title="Bollinger Bands Multiplier")

// RSI Calculation
rsi = ta.rsi(close, rsiLength)

// MACD Calculation
[macdLine, signalLine, _] = ta.macd(close, macdFastLength, macdSlowLength, macdSignalSmoothing)

// Bollinger Bands Calculation
basis = ta.sma(close, bbLength)
dev = bbMultiplier * ta.stdev(close, bbLength)
upperBand = basis + dev
lowerBand = basis - dev

// Buy condition
buySignal = (rsi < rsiOversold) and (macdLine > signalLine) and (close < lowerBand)

// Sell condition
sellSignal = (rsi > rsiOverbought) and (macdLine < signalLine) and (close > upperBand)

// Plot signals on chart
plotshape(series=buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// Plot Bollinger Bands
plot(upperBand, color=color.blue, linewidth=1, title="Upper Band")
plot(lowerBand, color=color.blue, linewidth=1, title="Lower Band")

// Plot MACD and Signal Line (optional, for reference)
hline(0, "Zero Line", color=color.gray)
plot(macdLine, color=color.blue, title="MACD Line")
plot(signalLine, color=color.orange, title="Signal Line")

// Alert conditions
alertcondition(buySignal, title="Buy Alert", message="Buy Signal")
alertcondition(sellSignal, title="Sell Alert", message="Sell Signal")
Candlestick analysis

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明