搜索
产品
社区
市场
新闻
经纪商
更多
CN
开始
社区
/
指标和策略
/
Highs, Lows, BOS, and Reversals
OPEN-SOURCE SCRIPT
Highs, Lows, BOS, and Reversals
由ankit4525提供
关注
关注
昨天
3
添加到收藏
添加到收藏
//
version
=5
indicator("Highs, Lows, BOS, and Reversals", overlay=true)
// User Input
length = input.int(10, minval=1, title="Length")
bosThreshold = input.float(0.5, title="BOS Threshold (%)") / 100 // BOS threshold percentage
// Highs and Lows Calculation
highestHigh = ta.highest(high, length)
lowestLow = ta.lowest(low, length)
// Plotting Highs and Lows as Lines
plot(highestHigh, color=color.red, linewidth=2, title="Highest High")
plot(lowestLow, color=color.green, linewidth=2, title="Lowest Low")
// Detecting Break of Structure (BOS)
var float previousHigh = na
var float previousLow = na
var bool bosUp = false
var bool bosDown = false
if (not na(previousHigh) and high > previousHigh)
bosUp := true
if (not na(previousLow) and low < previousLow)
bosDown := true
// BOS Conditions and Plotting
bosUpCondition = bosUp and high > previousHigh
bosDownCondition = bosDown and low < previousLow
plotshape(bosUpCondition, location=location.abovebar, color=color.blue, style=shape.labelup, title="BOS Up")
plotshape(bosDownCondition, location=location.belowbar, color=color.orange, style=shape.labeldown, title="BOS Down")
// Reversal Condition (Potential Reversal after BOS)
reversalUp = bosUpCondition and close > highestHigh
reversalDown = bosDownCondition and close < lowestLow
plotshape(reversalUp, location=location.abovebar, color=color.green, style=shape.labelup, title="Reversal Up")
plotshape(reversalDown, location=location.belowbar, color=color.red, style=shape.labeldown, title="Reversal Down")
// Store High and Low for Next Bar
previousHigh := highestHigh
previousLow := lowestLow
// Optional: Plot lines to visualize the highs and lows (for better clarity)
plotlineHigh = line.new(bar_index[length], highestHigh, bar_index, highestHigh, color=color.red, width=1, style=line.style_dotted)
plotlineLow = line.new(bar_index[length], lowestLow, bar_index, lowestLow, color=color.green, width=1, style=line.style_dotted)
Chart patterns
开源脚本
本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受
网站规则
约束。 您可以收藏它以在图表上使用。
想在图表上使用此脚本?
添加到收藏
ankit4525
关注
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在
使用条款
阅读更多信息。