Setting Dynamic TradingView Alerts

TradingView alert placeholders allow you to extract realtime data from the chart or indicators. You can retrieve a line value drawn by an indicator or the current position size used by a strategy. This is a robust feature that enable you to create dynamic alerts.

Featured Use Case
A popular indicator called Binary Arrows shows up and down arrows on the chart. Lets automate our IQ Option account. Since I am not on a paid plan on TradingView, I am restricted to only one alert. We will use placeholders to get the type of arrow drawn by the indicator.

  • {{plot_0}} EURUSD e=1 q=10 t=binary
    When a down arrow is shown, a put option of 10 usd will be made on our IQ Option. The {{plot_0}} will be replaced by a -1. An up arrow would be shown by the number 1.

Lets have a look at how much we can do with placeholders. TradingView has already documented it here but we will make it easier for you. We will start with the most useful examples. As you have been using TradingView To Anywhere automation tool, we will start with generating a command.


1. Buy/Sell placeholders

Most platforms accept the words buy, long, 1, sell, short or -1. We can generate this values dynamically from the following:

  • An arrow plot on the chart. The plot value of an arrow is either 1 for an up arrow which dictates a buy or -1 for a down arrow. Use the index of the plot to get the plot value. Example {{plot_2}} if arrows are the 3rd drawings on my script. See parameter values for more tips on plot values.
  • Strategy market position variable for strategy alerts to get the current strategy direction. Example {{strategy.market_position}} will return long if we get on a buy, short if we get on a sell and flat if the strategy closes the trade.
  • Strategy order action works similar to market position but only returns buy and sell. Example {{strategy.order.action}}

2. Parameter Values from plots

Another common case is adding dynamic parameters to your commands like take profits or stop losses. If your indicator or strategy draws these values on the chart, you can directly extract them to be part of your alert using the plot index placeholders. Going to the your indicator or strategy settings and styles section, you will see the list of plots.


In the above screenshot, stop loss is the third plot, followed by take profit. The index of plots start from zero, therefore our alert message would have sl={{plot_2}} tp={{plot_3}}. We can even do better, since the plots have names on this indicator, we can use sl={{plot("SL")}} tp={{plot("TP")}}. Notice how we always use the double curry braces - {{}} otherwise it will not work.

NB: You can only extract the first 20 plots of any strategy or indicator. To learn about more placeholders, have a look at How to use variable in alert by TradingView.

You probably have a lot of imaginations on what you can do with dynamic alert messages. I will leave you with the most useful example in my experience.

  • {{strategy.market_position}} oq=2% cq=100% sl={{plot("SL")}} tp={{plot("TP")}}

This alert will open 2% quantity when long or short command appears with set stop loss and take profit, and close 100% of my position when flat command appears.

Cheers and Happy Trading!

1 Like