Adding variables to alerts in pinescript

杀马特。学长 韩版系。学妹 提交于 2021-02-19 01:53:10

问题


I would like to use the same alert condition in a pine script for several stocks in TradingView. The problem is that I won't know which stock triggered the alert unless I create copies of the script and have a custom message for each script. I would like to have something like:

alertcondition(someCondition, title='Bullish', message=tickerid)

where I use the tickerid variable which is one of pine scripts built in variables. However, when I attempt this, the message I get is literally tickerid instead of the tickerid of the chart associated with the script. Is there any way to dynamically generate the tickerid?


回答1:


Stumbled upon your question just now and in case anyone else does too: Adding variables to the message of an alertcondition has been possible for a while. For example:

  • {{exchange}}
  • {{ticker}}
  • {{close}}
  • {{volume}}

(source)

PS Kodify.net has a thorough tutorial on this: https://kodify.net/tradingview/alerts/alert-variables/




回答2:


Unfortunately, message of alertcondition cannot be dynamic at the moment. First, 'tickerid' is a function that is executed on a server side. Second, the alertcondition message is an entity that does not go to the indicators server engine. It's a static text message that should be displayed when alert triggers. This is how it works, hopefully it will be improved in the future releases.



来源:https://stackoverflow.com/questions/48530411/adding-variables-to-alerts-in-pinescript

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