Page 1 of 1

Help - cannot get alert Message variables working

Posted: Thu Apr 15, 2021 12:24 am
by smaphead
I'm going nuts here -- been battling this problem for two days now. :sad1:

I have a strategy script running, generating strategy.entry/exits. The entry looks roughly like this:

Code: Select all

strategy.entry(id = 'buy',
 long = strategy.long,
 when = buy and candleTimeWithinBacktestRange,
 alert_message = "{'message_type': 'bot', 'bot_id': <my id>, 'email_token': '<my token>', 'delay_seconds': 0}")
 
My alerts are firing. I'm using {{strategy.order.alert_message}} in the alert Message, however that variable substitution never seems to work -- the Message is always empty.

The alerts show in the Alerts log with no message, and nothing is being triggered on 3commas.

I tried the same with a strategy comment and the result was the same.

Any ideas what I've done wrong?

Re: Help - cannot get alert Message variables working

Posted: Fri Apr 16, 2021 5:13 pm
by Deep-Wave
Hi smaphead,

I believe these references can help you:

https://www.tradingview.com/chart/?solution=43000481368
https://www.tradingview.com/blog/en/our ... ges-22588/

From your code, the "alert_message" from strategy.entry() is just plain string, nothing to substitute there.
When you create the strategy alert and you put "{{strategy.order.alert_message}}" in the alert message window, it should return the string value from the strategy.entry(): "{'message_type': 'bot', 'bot_id': <my id>, 'email_token': '<my token>', 'delay_seconds': 0}"

I hope this helps.

Cheers,

Re: Help - cannot get alert Message variables working

Posted: Fri Apr 16, 2021 5:44 pm
by smaphead
Thank you! I finally got it working late last night.

Evidently there was never anything wrong with my scripts. I simply re-created the alerts (exactly as they had been before) and they started working. So, it seems like the alerts were somehow "corrupted" or otherwise glitching.