Hey traders, hope you're doing well. Uh I've got an interesting one for you guys today. This is a message I received from a former student uh where he has this issue with a Trading View alert that was doing some weird behavior. So this alert should theoretically only fire one time and never again. We have a persistent V bull here. Alert created set to false when the script is first initialized. And then if the alert is not fired and we're on the last bar on our chart, we flip the bull value and trigger an alert. And then this alert should theoretically never trigger again because this is a persistent boolean. It's set to true now. And this check for if not alert created should fail forever and ever until we reset our alert. Right? That's what you think. That's the in sort of intuitive expected behavior of the script. But due to technical reasons, which I'll explain in a moment, that is not what happens. As this trader found out with this script, he said somewhere between every few hours, like 12 to 18 hours, the alert re-triggers randomly. Now, I've never encountered an issue like this. I've never noticed an issue like this because I've never had a script where I needed to trigger an alert once and never again. However, this brought my attention to something that I think we should all be aware of as traders. Just the technical inner workings of the Trading View alert servers is just good knowledge to have. What's happening here is the Trading View servers need to restart occasionally. Every server on the planet needs to restart occasionally to maintain smooth running. You know, for maybe it's a Windows server and it needs to process updates uh or needs to clear memory. There's a million reasons why servers need to restart regularly. Trading View is no different. When their Trading View alert servers restart, the script does not save this information to file. It's not persistent between restarts. It's persistent in memory. So, for as long as the server is running, this alert won't trigger again. But as soon as the servers restart or the instance is reset, I don't know how that works on the Trading View servers back end. But when the alert is refreshed or the server restarts, this bull is set back to false. The script re-executes and bar state. islast is going to be true again on a refresh of this script and the alert is going to trigger again. So in other words, what this trader has inadvertently discovered is a way to detect trading view server restarts. Uh which is you might think useless to know. But there is one niche use case for this which is debugging when alerts don't fire. So sometimes, very rarely, but sometimes I get messages from traders who say they had a Pine Connector alert, for example. Maybe they're autotrading a script through Pine Connector and one of their signals doesn't get processed by Pine Connector. The alert doesn't fire. Running this script could be a way to detect if that is related to a server restart. If you have a missed alert and you're running this alert and you notice that within a minute or a couple minutes of your missed alert, this alert fires, then you know that your alert was missed because the Trading View servers were not processing alerts at that time and they were either the servers crashed or they were down for maintenance or they restarted. Now, I would imagine Trading View being the big company they are, they'd have redundancies and servers that would take on the job of running your alerts if they were turning one off for maintenance. But issues happen with it stuff. Maybe the server crashes or something. This will tell you when the alert resets. Now, it might not be 100% accurate because I imagine Training View have multiple servers running, I imagine they might be segregated to different geographical regions. So maybe my alert depending where I set it. If I set it on my computer versus a dedicated server versus someone else on the other side of the world, maybe the alerts would be running on different server instances and this might not be useful at all. but it was just a thought that came to mind. So anyway, if you want to detect trading view server restarts, run this script and set alerts on it. If you need an alert to trigger once and only ever trigger once and never again for whatever reason, you need to take a different approach. So, this is a short script I made to detect server restarts, which I plan to run just for a little while, just to get some insight into how often the servers restart. And maybe if I set a couple up on dedicated servers in different geographical regions, I can actually figure this stuff out just out of curiosity. But if you want to have an alert trigger only once, then you need to use the alert condition function, which behaves a bit differently to the alert function. So here if I say bar state is last and we say um single fire alert and I'll change the name of the script and say alert triggered once and I save my code. If I now come up to my script here and I click add alert and I select single fire alert from the condition, that's my script. That's my alert condition. Um, if I get rid of that, it'll be a little easier to tell a difference uh that alert. So, we got single fire alert is my script. Single fire is my alert. And if I set this to only once, the alert will only trigger once and will not be repeated. So, this will be persistent across server restarts. The V keyword is not So if you're running into any strange issues with your scripts where your script depends on something to be persistent across server restarts, then now you know why that might be happening. Um anyway, to wrap up, one last thing to note is if you do need to use the alert condition function to trigger your alerts, you can't just append um values like this to the alert. It won't work. uh because the script is expecting a constant string. So what we need to do instead is use the placeholders which are these here. There are a bunch of inbuilt ones you can use or you can use your own placeholders if you need to add indicator values. There's also this documentation page on how alerts function under the hood which could be interesting if you're running into any issues with your alerts. So go and read that. There'll be a link to both of these below. And that's it for this video. Just a quick one, just a bit of an interesting technical issue that a trader ran into that I thought was interesting to do a quick little dive into um on the channel. Now, if you wanted to do the same time stamp as I had in the other script example, alert example, you can use this time placeholder. Anyway, that's it. I hope you guys found this interesting. If not, don't worry. There's plenty more content coming soon. Take care. I'll speak with you in the next lesson. Good luck with your trading.