Tradingview will always trigger alerts on OPEN and CLOSE of trades. This is because we use Order Fill method of alerts to trigger alerts for trading. This results in higher consistency and prevents repainting and duplicate alerts from firing. However, the side effect is that some bots may retrigger an order at the end of a trade rather than simply ending a trade if you're using the same message in Tradingview alerts.


Since you can't use placeholders in the strategy message boxes directly, the alternative to this is to use the strategy to filter open and close alerts.


You can filter out syntax from a bot message by using the strategy message boxes.



In the Tradingview alert, if you use 

{{strategy.order.alert_message}}


... it will send whatever is in the strategy message box. If you enable New Trade alerts, that's for open of a trade. If you enable Close Trade alerts, that's for all closes.

Let's say this is your bot syntax:


{ I'm a Bot! }


If you remove the front bracket and put it in the strategy, you will break the syntax. By breaking the syntax, the bot can't "read" the incoming message. In the strategy, you can input this message for long and short open


{ 


and in the Tradingview alert, it becomes this:

{{strategy.order.alert_message}} I'm a Bot! }




So when the strategy sends a New trade alert, you'll see this alert pop up

{ I'm a Bot! }



But when a close alert triggers, the front will not send, and you'll see this

 I'm a Bot! }


IMPORTANT: Alert message box placeholders are CASE-SENSITIVE. Using improper upper or lower case will cause the message being sent to return NA (an empty string). You should copy these texts exactly and paste them as is.