Tradingview has added the ability to pass custom variables into their alert messages. This is something the community has been requesting for a long time. The amount of customization this allows you to bring to your trading system is difficult to explain as there is little to no limits now.
To read more about setting your custom variables up in Tradingview, read their article here: https://www.tradingview.com/blog/en/introducing-variables-in-alerts-14880/
Manually inserted into alert message:
When calling a custom variable by typing your command into the alert message upon creation, you need to call the specific plot, plotchar, plotarrow.. Start counting each from the top of your script with the first plot being plot_0.
//@version=4
study("Testing Script")
plot(open, "Plot #1")
plot(close, "Plot #2")
plot(high, "Plot #3")
plot(low, "Plot #4")
alertcondition(close > 0, "test trigger")
In your alert, you would call the 4 plots above using this message:
open = {{plot_0}}
close = {{plot_1}}
high = {{plot_2}}
low = {{plot_3}}
By hovering over the alerts log, we can see that each value was passed accordingly.
Passing variables through an alertcondition():
Example script to
//@version=4
study("Dynamic Alerts")
lowestClose = lowest(close, 100)
plot(lowestClose, "lowestClose")
alertcondition(close > 0, "Test Trigger, message="b=long q=10 fp={{plot(\"lowestClose\")}}")
You can also include custom variables in an alert condition by escaping the quotes within the message.
alertcondition(close>1, message="e=bybittestnet s=BTCUSD b=long q=10 fp={{plot(\"lowestClose\")}} d=1")
Using the pipe character you can include multiple commands within a single alertcondition.
alertcondition(close>1, message="e=bybittestnet s=BTCUSD b=short c=position t=market d=1 | delay=3 | e=bybittestnet s=BTCUSD b=long q=10 fp={{plot(\"lowestClose\")}} d=1")
Here is what your alert condition would like when created. However, when it triggers the lowestClose is replaced by the relevant value before being passed through Autoview.
We hope these brief examples has you thinking about all the new possibilities with Autoview.
Comments
0 comments
Article is closed for comments.