最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

pine script - Alert When Price Drops Below X% of ATH - Stack Overflow

programmeradmin2浏览0评论

I’m struggling to write a script for tradingview in pine editor that triggers an alert when the all-time high (ATH) drops below a certain percentage, for example, 1%. Unfortunately, it gives me no alarm.

//@version=5
indicator("ATH - 1% Alarm", overlay=true)
ath = ta.highest(high, 5000)  // Calculates the ATH over the last 5000 candles
alert_level = ath * 0.99  // 1% below ATH (should be 20% in my case)
plot(alert_level, title="Alarm-Level", color=color.red, style=plot.style_stepline)

alertcondition(close < alert_level, title="ATH -1%", message="Price is 1% below ATH!")
plot(close)

I’m struggling to write a script for tradingview in pine editor that triggers an alert when the all-time high (ATH) drops below a certain percentage, for example, 1%. Unfortunately, it gives me no alarm.

//@version=5
indicator("ATH - 1% Alarm", overlay=true)
ath = ta.highest(high, 5000)  // Calculates the ATH over the last 5000 candles
alert_level = ath * 0.99  // 1% below ATH (should be 20% in my case)
plot(alert_level, title="Alarm-Level", color=color.red, style=plot.style_stepline)

alertcondition(close < alert_level, title="ATH -1%", message="Price is 1% below ATH!")
plot(close)
Share Improve this question asked Feb 14 at 14:34 BullzBullz 1
Add a comment  | 

1 Answer 1

Reset to default 0

For debug, plotchar you alertcondition

plotchar(close < alert_level)

Your script sends multiple alerts

To send a single alert, try this:

//@version=5
indicator("ATH - 1% Alarm", overlay=true)
ath = ta.highest(high, 5000)  // Calculates the ATH over the last 5000 candles
alert_level = ath * 0.99  // 1% below ATH (should be 20% in my case)
plot(alert_level, title="Alarm-Level", color=color.red, style=plot.style_stepline)

alertcondition(close < alert_level and close[1] > alert_level, title="ATH -1%", message="Price is 1% below ATH!")

plotchar(close < alert_level and close[1] > alert_level)

发布评论

评论列表(0)

  1. 暂无评论