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)
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.