OPEN-SOURCE SCRIPT

Simple H% Buy/Sell Signals

138
//version=5
indicator("Simple H% Buy/Sell Signals", overlay=true)

// === Calculate H% ===
h_percent = ((high - low) / low) * 100

// === Input thresholds ===
buyThreshold = input.float(0.3, title="Buy Signal H% Threshold")
sellThreshold = input.float(0.5, title="Sell Signal H% Threshold")

// === Buy/Sell Conditions ===
buySignal = h_percent > buyThreshold and close > open
sellSignal = h_percent > sellThreshold and close < open

// === Plot shapes ===
plotshape(buySignal, title="BUY Signal", location=location.belowbar, style=shape.labelup, text="BUY", color=color.green, textcolor=color.white, size=size.normal)
plotshape(sellSignal, title="SELL Signal", location=location.abovebar, style=shape.labeldown, text="SELL", color=color.red, textcolor=color.white, size=size.normal)

// === Optional: Plot H% for visual reference ===
plot(h_percent, title="H%", color=color.orange, linewidth=2, display=display.none)

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.