TradingView Pine Script Tutorial 20 – Custom Alert Messages With alertcondition

TradingView Pine Script Tutorial 20 – Custom Alert Messages With alertcondition

YouTube Video

YouTube Video Transcript

[Music] hey this is David for big bits and in this video we’re going to go over a function we have not covered yet and that is the alert condition and if you’ve seen the video title you know what we were going to do is we are going to create a custom alert message now if you’re not familiar with alerts and trading view you can use them to simply alert you with the pop-up on the screen they can send you an email and they can also hook into web hooks some people also use alerts for trading buzz there are some extensions I can’t really say anything about those I don’t really know too much about those but this this particular script was a request by one of the YouTube commenters and I appreciate that because I haven’t really looked into the alert conditions too much but we’ve got it figured out and I’m gonna show you exactly how this works so first of all as always in the video I’m going to show you our end result first especially for those of you don’t know how to make an alert this might be helpful first thing you need to do in particular we need to add this indicator and this is on my public scripts it should be in the public library soon once it gets indexed and what we’re doing is we’re adding this indicator but then we have to add an alert okay you open up the alerts tab here and make sure I’m not in the way on the other screen here then click here to create a new alert you can do that or you can hit the little plus button here let’s do this one now on the condition it’s referring to what indicator or what part of the chart you’re looking at so we want to actually select our custom alert message the indicator that we’re working with here if you’ve created your own with this code you would select whatever you named it and saved it now it’ll give us all of the different options for the alert conditions now these are built in number one and number two here are ones that we’ve created in this particular example and we’re just going to go ahead and select custom RSI I’m only going to have it show a pop-up you can see the message that it has set here and it’s going to pop up immediately well relatively immediately because of how I’ve got it set up we’ll go over that later but once you’re ready make sure you’ve got everything that you want selected for the actions on the alert as you can set an expiration time if you needed to and how often the alert can actually occur I’m only gonna do this once because this is just an example let’s go ahead and hit create should take just a moment and we should get a pop-up in the middle of screen there we go our RSI is 55 and a bunch of decimals and we could look here it’s 55 and a bunch of decimals so the alert work that showed us what the RSI value is and there’s plenty of documentation on how to do this if you click on create alert there’s a little plus button down here and if you haven’t noticed you can actually click on that and it can give you more information about the placeholders and the placeholders are those custom messages that we can put in using the indicators that we’ve plotted so if you want to put a custom value in there you have to plot it on the screen to get it to show up and they have a bunch of built in when such as the exchange the ticker the clothes volume things like that are already built then whereas the custom values that you want to use we are going to have to reference their plot using the plot ID now it’s very important that you remember that you’re using the plot ID not the plot title or any other combination of possible inputs you could possibly have here it has to be plots underscore the ID of the plot and the plot ID is determined by the order in which it’s plotted so now we can actually look at the code because now I kind of have to explain what that means what we’re gonna be looking at we’re gonna be looking at the RSI and just a simple EMA a three period EMA of the RSI and I have got this set to where it’s always going to be true we’re always going to get an alert whenever tradingview processes these alert conditions and that’s just because we’re doing this example I’ve made sure to comment in here remove this line if you’re going to copy this code because this will always make this create the alerts constantly no matter what you’re doing ideally what you would do is something like this creating a boolean and assign that true or false based on some sort of conditions and in this example it was you know I wanted the RSI to be less than 30 the RSI of the previous candle to have been less than 20 but the current RSI is greater than the last RSI so basically the RSI was really oversold and it’s moving up now it’s a really simple example but it just kind of gives you an idea of what you can do you can even compare different indicators all kinds of stuff if you want ideas for that stuff please go back and look at all the other videos in this series so far we’ve covered a lot of different stuff and if you want to combine different indicators there’s a lot of great resources in those videos now we are always going to have an alert but I told you we need to plot IDs so the first thing we’re going to be doing is we’re going to have to plot this information on the chart now we are going to plot our EMA our exponential moving average of the RSI first and we’re going to call that the plotted smooth RSI and it is the blue value on the indicator here now that would be plot ID zero and I probably should add to this earlier but that gives you the idea this is a zero indexed based array that they’re using to do those custom messages when they’re looking at the plots apparently they add the plots to the chart as an array and the first plot is a zero indexed so it starts with zero when you’re trying to reference it and this would be plot one because it is our second one in the zero based index so that would be number one now and just to further illustrate that we’re going to call our alert condition we’re going to tell it whether or not it should be triggered and we have it set to our boolean value our alert from back here we have it set to true right now but ideally like I said you have this set to some sort of condition multiple different parameters that you would use maybe you’re just looking to see if the price went up from before something like that you need to be watching for whether or not your conditions are true or false and you place that true or false value here then you can create a title personally I like to order those by number so that when you do look at them from the drop-down you can actually have those populated first I haven’t tested this yet but if you started it with the letter Z they might show up at the very end of this list so it’s in my opinion a good idea to just number them for yourself now like I said to further illustrate this plot one is our RSI you can see that here and you can also see we’re referencing plot one with the placeholder in the string now you don’t concatenate strings here in the previous video we concatenated strings in functions so that you could change securities with the message if you try to call a function such as two string and the RSI value it won’t let you save the script so don’t waste your time I tried that plenty of times to figure this out for the first time and you also can’t put in the values themselves so this is how it has to be done you have to call the plot if you wanted to you know maybe reference something that you didn’t want to show on your indicator you could actually plot that value and just make it set to its transparency having a 100 transparency which means you can’t see it on the screen but it’s still being plotted and you might still be able to interact with it when you hover over it and you could probably see the values over here on the indicator but if you didn’t want to see it on the indicator but you still wanted to reference it in the message you would just create another plot a plot to here set its transparency to 100 on the plot you wouldn’t be able to see it up here but you would be able to reference it in your messages plot too that’s just another example of how you can add more information in here now these don’t have to be just the single line just one different value in here if you wanted to you could do multiple placeholders you could do the RSI is equal to this then you do space current price is equal to the placeholder for the clothes and really you can do whatever you want you can even do calculated values but like I said in order to do that you have to plot those so that’s essentially what the I am a the the first one is here that’s another calculated value based off of the RSI so maybe we wanted to see what the absolute value of the MACD was for whatever reason so if it was a negative number it would actually be positive now I mean you could do that but you have to plot it first on the screen I can’t iterate that enough that’s the most important thing and then reference the correct plot ID and I hope this all makes sense it’s really not that hard once you do it but like I said this code is available on my trading view profile and you can see that here there’s a link in the description of the video go check that out you can click that and I’ll probably update the code just a little bit with some of those comments I added during the video but I hope you appreciated the video if you have any questions please leave a comment or if you have any other indicators or functions or anything related to trading view in Pyne script please leave a comment let me know what you’d like to see otherwise please like the video subscribe all of those things helped me quite a bit and definitely if you like these videos you probably do want to subscribe because there are going to be plenty more or there’s gonna be other video series coming up lots of things coming up in the channel so thank you very much for your time and have a great day [Music] you

YouTube Video Description

< br/> #bitcoin #crypto #cryptocurrencies #tradingview

Website: https://bigbits.io
Discord: https://discord.gg/rapMn4z
Twitter: https://twitter.com/BigBitsIO
Facebook: https://www.facebook.com/BigBitsIO/
GitHub: https://github.com/BigBitsIO
TradingView: https://www.tradingview.com/u/BigBitsIO

Referrals……
Trade on Coinbase: https://www.coinbase.com/join/johnso_dxz
TradingView: https://www.tradingview.com/gopro/?share_your_love=BigBitsIO
Brave Browser: https://brave.com/big406

DISCLAIMER: All my videos are for educational and entertainment purposes only. Nothing in this or any of my videos should be interpreted as financial advice or a recommendation to buy or sell any sort of security or investment including all types of crypto coins and tokens. Consult with a professional financial advisor before making any financial decisions. Investing in general and particularly with crypto trading especially is risky and has the potential for one to lose most or all of the initial investment. In simple terms, you are responsible for your actions when trading.

YouTube Automatically Generated Transcript (up to video description character limit):