0

I'm trying to create alerts with variables. I've seen this thread and this article, but I believe because my condition comes from a Security function, I'm having problems with creating the alerts.

s01 = input('DOTSDT', type=input.symbol)
screenerFunc() => triggerA and triggerB
c01 = security(s01, res, screenerFunc())
alertcondition(c01, title="ALERT!", "Look at " + S01)

If I try the above, I get a:

Cannot call 'alertcondition' with arguments (series[bool], title=literal string, message=input string)

If I try the following...

alertcondition(c01, title="ALERT!", message="Look at: {{ticker}}")

...I get a

Cannot use a mutable variable as an argument of the security function.


UPDATE

In fact, the issue seems to be using the security function as a condition for alertcondition rather than the use of any variable. I've tried to simply use a static message, but still get the same error Cannot use a mutable variable as an argument of the security function.

UPDATE!!!

I've created another thread, hopefully a more clear one:
“alertcondition” fails when the condition comes from a security function

Appreciate your help :-)

42piratas
  • 555
  • 1
  • 9
  • 26
  • 1
    Currently, the string variable cannot be added to the alert. Leave a feature request with TradingView via their support ticketing system. I think it is possible to add a placeholder {{label}} – AnyDozer Jan 23 '21 at 15:06
  • @AnyDozer I don't understand. My issue is the condition. So do you mean it doesn't accept a string variable as a condition? Even if in this case my variable returns a boolean? (the return of the screenerFunc() is a boolean) – 42piratas Jan 23 '21 at 17:13
  • 1
    I realized that there are two questions. It is problematic to help without your script with an error in the condition, but even if you eliminate this error, the issue with the variable message in the alert will remain open. – AnyDozer Jan 23 '21 at 17:36
  • 1
    If it is not possible to lay out the entire script, try to make a full fragment with an error that should work. – AnyDozer Jan 23 '21 at 17:48
  • 1
    See also my answer to this [question](https://stackoverflow.com/questions/65825212/pinescript-use-text-variable-in-alerts) – AnyDozer Jan 23 '21 at 18:43
  • @AnyDozer I'm sorry for the poor formulation in my question I've created a (hopefully) better question, where I also have a link to the entire code. Thank you https://stackoverflow.com/questions/65863553/alertcondition-fails-when-the-condition-comes-from-a-security-function – 42piratas Jan 23 '21 at 19:35
  • 1
    Now it can be done. New alert features are [here](https://www.tradingview.com/blog/en/our-new-alerts-allow-for-dynamic-messages-22588/) – AnyDozer Jan 25 '21 at 17:46
  • @AnyDozer Thank you so much for letting me know, I really really appreciate it! I've just updated the code. Cheers! https://github.com/42piratas/misc/blob/master/tradingview/screening_gridbots.pine – 42piratas Jan 25 '21 at 23:47

0 Answers0