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)
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.