7

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?

Eric
  • 1,209
  • 1
  • 17
  • 34
  • did you ever figure this out? I'd like to know how to console.log variables in pine-script. – zero_cool Feb 07 '18 at 04:52
  • 1
    No. I don't think that it's actually possible, so I'm using the ccxt library to grab the info my self and do the TA myself outside of trading view. – Eric Feb 07 '18 at 13:11
  • Interesting. I'd like to be able to port some of the amazing work by the Trading View community into Go, or Javascript. Have you found a way to determine whether the TA you are accomplishing with ccxt is equivalent to the trading view scripts? It's a little crazy, that logging does not exist in pine. – zero_cool Feb 07 '18 at 17:59
  • I can't speak for all of the indicators as I literally just got started (hence the recent question!). However, so far things look like the match up when I use ccxt with TA-lib. – Eric Feb 08 '18 at 13:27

2 Answers2

4

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.

vitvlkv
  • 782
  • 7
  • 13
4

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/

Harm
  • 590
  • 3
  • 21