smaphead
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: April 15th, 2021

Help - cannot get alert Message variables working

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?

Deep-Wave
Pine Script Master
Pine Script Master
Posts: 44
Joined: September 4th, 2020
Contact: TradingView Profile

Re: Help - cannot get alert Message variables working

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,

smaphead
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: April 15th, 2021

Re: Help - cannot get alert Message variables working

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.

Return to “Pine Script Q&A”