PROTECTED SOURCE SCRIPT

突破鬧鐘

12
//version=5
indicator("突破鬧鐘", overlay=true)
prevHigh = high[1]
prevLow = low[1]
var label activeLabel = na
var int activeDirection = 0

isBreakHigh = high >= prevHigh
isBreakLow = low <= prevLow

if activeDirection == 1 and low < prevHigh
label.delete(activeLabel)
activeLabel := na
activeDirection := 0
if activeDirection == -1 and high > prevLow
label.delete(activeLabel)
activeLabel := na
activeDirection := 0

if isBreakHigh and activeDirection != 1
if not na(activeLabel)
label.delete(activeLabel)
activeLabel := label.new(bar_index, low, text="突破前高: " + str.tostring(prevHigh), style=label.style_label_up, color=color.green, textcolor=color.white, yloc=yloc.belowbar)
activeDirection := 1

if isBreakLow and activeDirection != -1
if not na(activeLabel)
label.delete(activeLabel)
activeLabel := label.new(bar_index, high, text="跌破前低: " + str.tostring(prevLow), style=label.style_label_down, color=color.red, textcolor=color.white, yloc=yloc.abovebar)
activeDirection := -1

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.