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 de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.