OPEN-SOURCE SCRIPT
BR-DowTheory

//version=6
indicator("BTC道氏趋势指标", overlay=true, shorttitle="BTC Dow", precision=2)
// 1. 参数设置
trend_length = input.int(10, title="趋势周期", minval=5)
vol_length = input.int(15, title="成交量周期", minval=5)
stop_loss = input.float(50.0, title="止损点数")
tp_ratio = input.float(2.0, title="止盈倍数")
vol_threshold = input.float(1.2, title="放量阈值")
// 2. 趋势判断
uptrend = close > ta.highest(high, trend_length)[1]
downtrend = close < ta.lowest(low, trend_length)[1]
// 3. 放量信号
vol_ma = ta.sma(volume, vol_length)
vol_bull = volume >= vol_ma * vol_threshold and close > open
vol_bear = volume >= vol_ma * vol_threshold and close < open
// 4. 开仓信号(去重)
var string last_signal = na
long_signal = uptrend and vol_bull and last_signal != "long"
short_signal = downtrend and vol_bear and last_signal != "short"
if long_signal
last_signal := "long"
if short_signal
last_signal := "short"
// 5. 开仓价与止损止盈
var float long_entry = na
var float short_entry = na
if long_signal
long_entry := close
short_entry := na
if short_signal
short_entry := close
long_entry := na
long_sl = long_entry - stop_loss
long_tp = long_entry + stop_loss * tp_ratio
short_sl = short_entry + stop_loss
short_tp = short_entry - stop_loss * tp_ratio
// 6. 绘制信号与线条
plotshape(long_signal, title="做多", location=location.belowbar, color=color.green, style=shape.labelup, text="L", textcolor=color.white)
plotshape(short_signal, title="做空", location=location.abovebar, color=color.red, style=shape.labeldown, text="S", textcolor=color.white)
plot(long_sl, title="多止损", color=color.red, style=plot.style_linebr)
plot(long_tp, title="多止盈", color=color.blue, style=plot.style_linebr)
plot(short_sl, title="空止损", color=color.red, style=plot.style_linebr)
plot(short_tp, title="空止盈", color=color.blue, style=plot.style_linebr)
// 7. 背景色
bgcolor(uptrend ? color.new(color.green, 90) : downtrend ? color.new(color.red, 90) : na)
indicator("BTC道氏趋势指标", overlay=true, shorttitle="BTC Dow", precision=2)
// 1. 参数设置
trend_length = input.int(10, title="趋势周期", minval=5)
vol_length = input.int(15, title="成交量周期", minval=5)
stop_loss = input.float(50.0, title="止损点数")
tp_ratio = input.float(2.0, title="止盈倍数")
vol_threshold = input.float(1.2, title="放量阈值")
// 2. 趋势判断
uptrend = close > ta.highest(high, trend_length)[1]
downtrend = close < ta.lowest(low, trend_length)[1]
// 3. 放量信号
vol_ma = ta.sma(volume, vol_length)
vol_bull = volume >= vol_ma * vol_threshold and close > open
vol_bear = volume >= vol_ma * vol_threshold and close < open
// 4. 开仓信号(去重)
var string last_signal = na
long_signal = uptrend and vol_bull and last_signal != "long"
short_signal = downtrend and vol_bear and last_signal != "short"
if long_signal
last_signal := "long"
if short_signal
last_signal := "short"
// 5. 开仓价与止损止盈
var float long_entry = na
var float short_entry = na
if long_signal
long_entry := close
short_entry := na
if short_signal
short_entry := close
long_entry := na
long_sl = long_entry - stop_loss
long_tp = long_entry + stop_loss * tp_ratio
short_sl = short_entry + stop_loss
short_tp = short_entry - stop_loss * tp_ratio
// 6. 绘制信号与线条
plotshape(long_signal, title="做多", location=location.belowbar, color=color.green, style=shape.labelup, text="L", textcolor=color.white)
plotshape(short_signal, title="做空", location=location.abovebar, color=color.red, style=shape.labeldown, text="S", textcolor=color.white)
plot(long_sl, title="多止损", color=color.red, style=plot.style_linebr)
plot(long_tp, title="多止盈", color=color.blue, style=plot.style_linebr)
plot(short_sl, title="空止损", color=color.red, style=plot.style_linebr)
plot(short_tp, title="空止盈", color=color.blue, style=plot.style_linebr)
// 7. 背景色
bgcolor(uptrend ? color.new(color.green, 90) : downtrend ? color.new(color.red, 90) : na)
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。