本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=5
indicator("Smart Money Analysis with Golden/Death Cross", overlay=true)
//-----------------------------------------------------------------------------{
// Input parameters
//-----------------------------------------------------------------------------}
short_sma_length = input.int(50, title="Short SMA Length")
long_sma_length = input.int(200, title="Long SMA Length")
vol_multiplier = input.float(1.5, title="Volume Multiplier")
support_resistance_period = input.int(20, title="Support/Resistance Period")
//-----------------------------------------------------------------------------{
// Obtaining price and volume data
//-----------------------------------------------------------------------------}
price = close
//-----------------------------------------------------------------------------{
// moving averages
//-----------------------------------------------------------------------------}
short_sma = ta.sma(price, short_sma_length)
long_sma = ta.sma(price, long_sma_length)
//-----------------------------------------------------------------------------{
// The logic of "smart money
//-----------------------------------------------------------------------------}
high_volume = volume > ta.sma(volume, short_sma_length) * vol_multiplier
//-----------------------------------------------------------------------------{
// Support and resistance levels
//-----------------------------------------------------------------------------}
highest_high = ta.highest(high, support_resistance_period)
lowest_low = ta.lowest(low, support_resistance_period)
//-----------------------------------------------------------------------------{
// Generation of purchase and sale signals based on SMA, volume and support/resistance levels
//-----------------------------------------------------------------------------}
buy_signal = ta.crossover(short_sma, long_sma) and high_volume and close > highest_high
sell_signal = ta.crossunder(short_sma, long_sma) and high_volume and close < lowest_low
//-----------------------------------------------------------------------------{
// Golden Cross and Death Cross
//-----------------------------------------------------------------------------}
golden_cross = ta.crossover(short_sma, long_sma)
death_cross = ta.crossunder(short_sma, long_sma)
//-----------------------------------------------------------------------------{
// Display of signals on the chart
//-----------------------------------------------------------------------------}
plotshape(series=buy_signal, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY", textcolor=color.white)
plotshape(series=sell_signal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL", textcolor=color.white)
//-----------------------------------------------------------------------------{
// Displaying Golden Cross and Death Cross on Graphics
//-----------------------------------------------------------------------------}
plotshape(series=golden_cross, location=location.belowbar, color=#52f321, style=shape.triangleup, title="Golden Cross", text="GOLDEN", textcolor=#3ff108)
plotshape(series=death_cross, location=location.abovebar, color=#ff3c00, style=shape.triangledown, title="Death Cross", text="DEATH", textcolor=color.rgb(248, 13, 64))
//-----------------------------------------------------------------------------{
// Displaying moving averages on a chart
//-----------------------------------------------------------------------------}
plot(short_sma, color=color.blue, title="Short SMA")
plot(long_sma, color=color.orange, title="Long SMA")
//-----------------------------------------------------------------------------{
// Display support and resistance levels
//-----------------------------------------------------------------------------}
plot(highest_high, color=color.red, title="Resistance Level")
plot(lowest_low, color=color.green, title="Support Level")
//[YourTradingSensei]