OPEN-SOURCE SCRIPT

Breakout Stock Identifier

//version=5
indicator("Breakout Stock Identifier", overlay=true)

// Input parameters
lookback = input.int(20, "Lookback Period", minval=1)
volume_threshold = input.float(1.5, "Volume Threshold", minval=1.0, step=0.1)
breakout_percentage = input.float(2.0, "Breakout Percentage", minval=0.1, step=0.1)

// Calculate moving averages
sma20 = ta.sma(close, 20)
sma50 = ta.sma(close, 50)
sma200 = ta.sma(close, 200)

// Identify trend
uptrend = sma20 > sma50 and sma50 > sma200
downtrend = sma20 < sma50 and sma50 < sma200

// Calculate average volume
avg_volume = ta.sma(volume, lookback)

// Identify volume spike
volume_spike = volume > (avg_volume * volume_threshold)

// Calculate price range
highest_high = ta.highest(high, lookback)
lowest_low = ta.lowest(low, lookback)

// Detect breakout
breakout_up = close > highest_high * (1 + breakout_percentage / 100) and uptrend
breakout_down = close < lowest_low * (1 - breakout_percentage / 100) and downtrend

// Combine conditions for final breakout signal
breakout_signal = (breakout_up or breakout_down) and volume_spike

// Plot signals
plotshape(breakout_signal and breakout_up, title="Bullish Breakout", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(breakout_signal and breakout_down, title="Bearish Breakout", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)

// Plot moving averages
plot(sma20, color=color.blue, title="SMA 20")
plot(sma50, color=color.green, title="SMA 50")
plot(sma200, color=color.red, title="SMA 200")

// Alert condition
alertcondition(breakout_signal, title="Breakout Detected", message="Potential breakout detected!")
Chart patternseducationalTrend Analysis

开源脚本

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

想在图表上使用此脚本?

免责声明