Pinescript: Use text variable in Alerts

旧街凉风 提交于 2021-02-05 09:28:31

问题


I wish to include a text variable in the alertcondition. I am using alertcondition(scr_label!="" ,title="1.Screener ALert",message="Screener Alert:"+scr_label)

Here scr_label is a dynamic text variable and I want the alert to give me that as the alert message. However if fires an alert without any message.

How can I achieve this?


回答1:


Detailed description in the documentation

Help Center•Alerts•Alerts settings• How to use a variable value in alert

The ability to generate variable text in alerts is very limited. I couldn't output a string variable in the alerts. In the following snippet, a workaround is how to output a color type variable in an alert.

plot(ColorS == #FF8C00 ? 1 : -1, title="colorA", display=display.none)
alertcondition(cross(LagFF,LagFS) and ColorF==ColorS, title='LagF', message='LagF cross {{ticker}} {{interval}} Up/Down {{plot("colorA")}}' )

Leave a feature request with TradingView via their support ticketing system. I think it is possible to add a placeholder {{label}}.

[ADDED]

Now you can do it like this

if scr_label!=""
    alert("Screener Alert:"+scr_label, alert.freq_once_per_bar_close)


来源:https://stackoverflow.com/questions/65825212/pinescript-use-text-variable-in-alerts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!