Make a DISCORD BOT out of TradingView alerts 🤖

broken image
broken image

 

broken image

To provide help to hooked up your cyber web hook. on your discord server. so this is assuming you already have a. discord server custom discord server. that you've got admin privileges for if. you do not know how to do this i'm not. going to assist you to set that up in. today's video because it's outside of. the scope of what i am coaching today. there's plenty of tutorials accessible if. you are attracted to that. but if you have already acquired your server. hooked up. all you need to do as a way to create. your cyber web hook. to ship this data to from buying and selling. view is good click your server. come all the way down to server settings after which. click integrations. next you must click on internet hooks right here. after which click create new cyber web hook this. button right here. and then we have our sort of cyber web hook. production interface here you could name. your bot whatever you want it doesn't.

subject what you name it due to the fact we can. override that. with our trading view signals. but the some thing you do have the desire to make. sure you set up actually is your. channel. we cannot difference what channel our. message is distributed to once it's hooked up so. ensure you select the right channel. right here that you want to use. so for state-of-the-art lesson i'm going to come. down and select. i will choose confidential sandbox this. is a customized confidential channel i've created. in my discord for checking out stuff that no. one else aside from me can see so i am. going to click on that and i'm going to. call this issue . um simply. test bot for now and i am not likely to. hassle with the avatar. i'm going to store adjustments and now we. have our web hook bot installed. so that's actually all you must do. at the discord side let's leap again over. to the pine editor and i'll show you the.

Script that i wrote so it is a paintings in. development i'll upload more functions. to this script as i find the time. to be honest it's not a big priority. for me immediately but i figured whilst. i'm doing this i'd as well turn it. into a lesson to educate you guys. whatever just a little distinctive. so the first thing i do within the  script. except get our user input is declare. about a fixed variables. so fixed simply means these do not. difference i in no way difference these in the. script and they're var variables so. they're persistent so on the first actual. bar on our chart these three variables. get initialized and their values never. difference. the first importance is our function identity thiis just. converts our position. id from the settings menu. into the proper discord syntax so. that it correctly tags that position over on.

Discord. if i were to just. um. crypto to illustrate if i have been to ship. this message. um as a. human person in this uh channel this would. in fact tag the crypto position but when i. become simply to jot down at crypto in my alert. text it'd just appear as text and. it will not tag the user. the discord syntax for bots specially. just for bots to tag roles. is the open arrow or left arrow the and. signal and then the role identity the discord. function identity. so if i right click my server come. right down to server settings roles. if i correct click the crypto role and. click copy identification and return here. it's the identification i must. reference when i'm trying to. ping this role so we want the left arrow. and sign and at signal after which near that. off with the right arrow this here. could appear as if this. when this message receives despatched from our cyber web. hook bot to discord so that's an.

significant aspect to mention if you wish. to tag a consumer then it looks like this. you eliminate the and sign and then you. need to. replica  the user identification and paste that in there. so if i reproduction. my bot identity. we would need to move at. like that. but we're just operating with roles today. so let's jump returned over to the pine. editor. and circulate on the subsequent fixed variable. here's our icon url so if the logo. information sort. so the marketplace kind we're presently. loaded onto our chart is equal to 4x. then we're on a foreign exchange industry and iinstead. of sending our icon url from the. settings menu. i ship a flag icon so it's my web site. right here we are getting the art of buying and selling. dot com forward scale down documents forward. cut down discord ahead scale back flags and. then the base forex is going to be. the 1st. 3 letters in the symbol ticker. so if i were to set an alert in this.

market at present this would be grew to become. into all of this ahead cut down aud. dot png and we might get the aussie flag. otherwise if we're not on a currency trading. marketplace then we reference the icon url. from the settings menu and you can set. that to anything you desire it is just a. hyperlink just a url to any photo dossier. equal with the avatar url which we will get. to in a second. subsequent up we've our market constant. variable and i'll explain what that is. used for later it isn't significant it. does not get sent in the alert or. whatever like that aanyway the subsequent issue . i do is just get the data i want to ship. to discord so for that reason i'm really. getting the proportion difference. of the closing price. compared the current remaining cost. compared to the previous closing price. so we are dividing that aand then. multiplying by way of 100 with a view to flip that.

Into a percent and then i'm additionally . getting the rsi. of the present market. and you may use the safety function. right here to reference other markets other. time frames etc i am simply retaining this. easy we're just referencing the. present marketplace we're on so that we will. simply set an alert. in this marketplace. after which when the alert fires it is going to. reference the current market's data next. up i wished a custom function to. truncate which is a fancy be aware for reduce. the excess decimal places so if you find yourself. sending some  alerts. to thirdparty apis to discord in this. case. many times if you ship a price like if we. send the rsi on our chart the rsi might. be. 70.51. or whatsoever. but if it is despatched while that range is. sent to the third celebration api it may. have like a dozen decimal places and. it's just ridiculous. so this practice operate here truncates.

The numbers decimal places to . we'd like it to be so as an example if i. wanted to truncate the rsi's significance we. could say rsi truncated. i do not know if that's a note yet let's. just pick that. it's set to. after which we might use truncate. and then circulate in our industry rsi variable. this man right here. comma. after which how many decimal places we want. to scale back to so if i put  in there. then we would simply have two decimal. locations after the total number of our rsi. value. now here is the most intricate portion of. the script in which we convert our values. and all of the settings information every thing we. have right here into json layout. to ship to the discord webhook so i've. got a custom operate here. all of this code will be within the  video. description a link to it will be in the. video description you could simply copy and. paste this complete script into your.

Editor and mess around with it but here. is. the embed json code for discord from. pinescript allow me paste it in here. and it seems like a big mess but i am going to. explain what is taking place here we have. our embed parameters so the colour of the. embed that is the this is the actual. colour you will see that we have a red color. in this embed a white one in this one a. green one on this one so that's our. first parameter. a second parameter is the writer. the third is the name fourth is the url. and it really is the url of the title so if i. go back over to discord therefore aud. takes me to the trading view chart that. i set this alert on in order that url. parameter turns the identify right into a hyperlink so. this title turns into a link to this url. next up we have our icon url when we. name this operate later within the  script. we pass it this icon url fixed.

Variable which keep in mind. sends a flag icon if this is a currency trading. pair or else it simply sends the icon. url from our settings menu. subsequent up we have an outline. after which we have this variable here. which i will eliminate as i am not. presently utilizing that so if i bounce lower back. over to. discord that is our description. that is our name it is our author. it really is our icon url it's our color. that is our content message. and the position tag. this is our avatar url. we are able to set this to any image we wish to. and our bot name may be sent to whatever. we need and that actually makes up. uh your usual discord message sent. from a bot i am going to depart a link in the. video description to a resource an exceptionally. effortless source if i deliver this up right here. this website right here has an excellent. bunch of guides right here tutorials on how to. use the several embed.

Parameters so you've got a footer if. you wanted to. and that places a touch footer on the top. right here with an icon url and in reality we. could use this. later in our script to set the quote. foreign money. flag photograph so at this time we basically have the. aussie flag on right here we could set a. footer less than this description right here that. has the canadian flag photo in it right here. and then a little footer right here if we. wanted to so maybe we are going to check out that. um in the direction of the tip of this lesson and to. remind myself i'm simply going to stick. the comment in right here. to this footer code and we will come back. to this later yet besides there's a complete. bunch of data here you can ship. pictures and all sorts of factors. and you'll do all of thiis through json. utilizing your pine script indicators yet today. we are simply going to focus on the basics. i don't want this lesson to be.

Too problematic so let me cross over this. operate certainly soon the first thing. we do is installed bot textual content that is our. username of our bot you will see all. those backslash. and quotation marks right here the backslash. is an get away man or woman now in most . programming languages including. panscript definitely. we use citation marks to. declare a string so when we're working. with strings or textual content we have to use. quotation mails to inform panscript that. this is not code this is text that we. want to send someplace or show. someplace but when we want to use. citation marks in our text. you cannot simply. do a gaggle of citation marks due to the fact. pinescript thinks it is just aa bunch. of blank strings facet by way of part and it. will you'll get collect errors in case you do. that so rather what we have to do is. use the backslash or break out individual.

And then installed our citation marks so. now you can see it is a complete string. but when we send this to discord or any. anyplace else or exhibit it on our. display or whatsoever we do with this the. backslash would be basically deleted and. it truly is what our text will appear as if. but pinescript understands that we wish to. incorporate this citation mark withiin this. string so that's why this looks so messy. and iit's a bit of a headache to write. out the style i did this turned into i simply established. my. embed how i desired to in notepad and. then i pasted that code into the pine. editor and i simply backspaced everything. and added backslashes. for all the citation marks. and just added a string on the tip like. that. it took me a little while to get. every thing lining up flawlessly yet. that is what thiis giant string here. truly is it's only one long json.

 

 

String that sends all of our several. parameters so we have our username which. is our bot name our avatar url that is. the url to our. photograph. our profile picture of the bot then we. have our tag textual content uh what this variable. this is doing is it's announcing is our. message clean  so allow me make this slightly. bigger and open up the settings menu. here it truly is our message parameter. lets  set this to anything we'd like. like hello it is a marketplace replace. or you can go away it clean  after which there. is not any textual content that gets sent to discord. this article is. this text right here. before the embed so it's optional you. don't need to comprise this and you don't. even desire to include a role if you don't. desire to you could simply ship an embed. with out the position and devoid of the message. in our script the way you do that is you. might just make the two of these textual content packing containers.

Blank. and then this. tag text would come to be just being a blank. string due to the fact here we first check is. message blank. and is roll clean  in that case then set our tag. textual content to blank in any other case. if message is not blank or roll is not. blank then we set our content material parameter. and then we specify. is our message clean  if so then we simply. upload nothing to the content material parameter. just but otherwise. if message is not blank then we upload that. message text to our content material tag or. parameter then we add a space on the tip. after which we add our function identification fixed. that is this guy here and this does the. same issue  it checks is roll blank. if so simply ship a blank string. otherwise. specify our position ping tag with the. correct syntax that you'll be able to see right here so. this function identification will be an extended range like. you spot right here and the way you get that. position idea as i confirmed you earlier is you.

terrific click the position call. anywhere in discord and click replica  identity i. imagine you ought to turn on. some  kind of setting in the settings. menu simply google that if you don't have. the option to repeat ids just google how. to copy discord ids there's numerous. data on that accessible so that's. our tag text next up we return the rest. of our textual content so thiis just. variety of merges every thing collectively so we. merge. our bot textual content our tag text after which our. embed code we have our title right here we. have our url for the title we have our. colour of the embed we've our. description of the embed we've our. author name. accordingly that is going to be the. industry we're presently on. and the url. of that aauthor so with the aid of default that is simply. set to an identical url as our title but if. you desired to you have two. extraordinary urls here so that when you.

click on. both this. this will take you to at least one url after which. you could make it so that after you click on. on the market it takes you to a. distinctive url if you wanted to i've simply. set it up in order that both take you to the. equal url then next up we have our icon. url this is the icon. of the writer accordingly it truly is our. flag icon for foreign exchange markets and if we're. now not on a forex industry then it sends. whatsoever photograph you install to this. putting here by means of default it's simply set to. my emblem. for. my enterprise so it's aactually quite simple. it purely looks complex because we're. just handling json syntax in. pinescript which. you know if we were to see this in plain. text it would seem a lot more like this. so this can be a lot less difficult to read than. what we're handling. but basically you will simply write out. what you need to reveal and then as i.

confirmed you earlier you could layout it in. pine script after you've written it out. in simple  text like this it's a lot. less difficult to do it that manner than to try to. write it out with all these backslashes. just remember that if you are. specifying all of your keys you would like. quotation marks around them but if. you're specifying your values now not all of. them want quotations so your colour for. instance is just a number of so you don't. desire to put quotations around this and. same with although it appears like you could. on the way to. but it's the same with. booleans you don't want to place. quotations around your booleans or the. there is aa good chance the message won't. paintings. and this is aa good time to say that. if you don't want to apply embeds and also you. simply want to keep it surely easy and. simply ship an easy. line of textual content to your discord use the.

content material tag it's a lot easier it's simply. one curly bracket one open curly bracket. then content in citation marks colon. after which a string and this string may be. anything and that gets sent to discord. identical to this so so that it will make a. genuinely easy discord bot through. coaching view just use those in preference to. embeds yet i just like the seem of embeds so. i went with that rather plus you could. upload pictures and funky stuff like that. so that's the important part of the. script blanketed the first 0.5  subsequent up. all we have to do. is. send this knowledge to discord utilizing. an alert so permit me paste this code in. here. so the style i have completed it truly is i determine if. the bar state is verified this boolean. magnitude this in-built variable is just set. to real on the last ultimate replace of. the present bar or in other words the. ultimate tick of the current bar before a.

New bar begins. so if the bar state is final within the . act of last on the final tick then we. get a gaggle of information when we ship. it using the alert. function and how we'd use this. is we might create a brand new alert select our. script and input the webhook url that we. created in the beginning of this lesson yet. we are going to get to that in a moment. so first thing i do before we ship. this facts to. discord is i am getting about a strings. here just to hold my code tidy or as. tidy as attainable i broke up our message. into distinct variables. the first one is our time-frame this. variable. receives the current time frame we're on if. it's an intraday. uh timeframe we're on then this article. right here will say our timeframe. interval  plus minute so if i was at the. 4 hour timeframe this would say 240. minute. if i used to be on the 5 minute time frame this.

would say 5 minute. or else if this isn't an intraday. timeframe yet it's aa daily time-frame. then our time-frame variable is determined to. daily and i simply realized we don't want. the spaces here. eliminate all the spaces. so if the timeframe is day-by-day then our. time-frame is decided to day-by-day. if i just set this variable to. time frame.period then this will simply be. d. to be able to make it a little more readable on. discord i convert. the d of the daily timeframe period. into day-by-day same with the weekly if we're. at the weekly time frame then it is set. to weekly instead of just w. and if we are within the  monthly it is set to. monthly or else if we aren't on any of. those time frames i don't know what time. frame we're on and so i just set it to. clean  so this is all completed within. parentheses so. this type of will be selected out of our.

truth or dare discord bot  once we've simply. uh observed which one we are on then we. add the textual content. time-frame to the top of that so if. we are at the 5  minute time-frame this. time frame variable would say 5  area. minute space time frame. just to make it more readable on discord. next up we have our replace it truly is the. replace we wish to send. this is basically our. turning our marketplace information that we have. up right here into readable textual content. so here. we're asserting sim details symbolinfo.ticker. that could say audusd. area ended space after which we examine did. the industry difference. is the marketplace difference variable it is a. percent change remember of the. present bar if the present bar's. percent change changed into positive or above. zero then we say. au. aud usd to that end ended up. after which. our market transformed percentage. or if it turned into no longer above zero then it.

 

 

Ended down. after which our industry change percent. and here we'd like to convert our marketplace. difference importance into a string or we are going to get. a assemble mistakes so you can not upload a. quantity on to a string we need to. convert that string into textual content. we do this utilizing the tostring operate. after which here's my truncate. method the customized variable customized sorry. function i created right here. that converts. this market difference percentage significance into. a. quantity with two decimal places so that. we don't have 1500 million you know. numbers after our. decimal region then we upload the proportion. sign on  the tip of that textual content then we are saying. which timeframe this data is from. which is simply passing the variable we. created up here. so. on time-frame after which in brackets we. have our rsi importance and returned we convert. that value to a string and we truncate.

It right down to  decimal locations so if i. jump returned over to discord it is. exactly what that seems like now i know. it's aa lot of paintings to get an easy. sentence sent to discord. but the beauty of this. variety of code is that when it is written. we are able to practically set these signals on. any industry we wish to and the tough. work's done that's why i admire utilizing. customized functions and stuff for this. because now this entire script is. reuusaable and i've set numerous alerts on. distinctive markets. to keep updating the users of my discord. on any significant industry hobbies which includes. you will see i have a few bitcoin i am. going to add to the crypto signals after I. get around to it yet this will notify. you each time. um bitcoin volatility selections up so. bitcoin rises or falls 10 with uh in an. intraday term in the day. you'll get alerted on discord if bitcoin.

Is damaged out of its twoweek number on. excessive quantity you'll get a alert. due to the fact which can predicate a bigger. flow incoming. um and then i just have easy forex. alerts. that just update you on wherein the. markets end of the day uh some thing you. would add to this if you wanted to and i. maybe must have i don't know why i. didn't. is the uh. cost. of this market. so. um i do not know in which the finest place to. do this would be. um let's do it here perhaps let's add a. open rectangular bracket plus two string. near plus. near square bracket so now we are going to have. have in rectangular brackets the actual cost. of this symbol so that's it next up we. have our content material which just generates. the json. this passes all this information to our. customized operate right here and converts it. into json layout in order that we are able to send. that information in our alert so i would like.

To remove this boolean due to the fact we're. now not using that aat the moment. that boolean turned into to feature fields i was. going to mess around with including a number of. distinctive fields to the embed yet i don't. suppose that is a good suggestion. for this actual use case in case you. desired to ship like maybe stock data. perhaps you desired to pull financials from. a industry or um dissimilar indicator. readings from a market you might want to. look at using fields. which again this um guide here should help. you with if you go to fields here if i. scroll down you'll find. if you wanted to you could ship an entire. bunch of indicator values or anything. for a particular marketplace utilizing fields. instead of utilizing numerous embeds. it looks a lot tidier but we can't conceal. that in state-of-the-art lesson because it's. going to be too much data. one thing more i did with my script is.

I added a volatility. alert so if i paste this block of code. in right here that is the exact same as this. code right here the sole change is rather. of looking forward to the bar to shut. we are checking if the present bars. difference percentage. the absolute importance of the present. markets difference percentage so successful or. damaging if it has moved 10 percentage up. or down within the current bar and the. user has turned volatility on in the. settings menu it's on via default then. this alert will be sent to discord and. that's simply telling you that there is a. excessive volatility alert. the sole change genuinely with this. code. back i ought to add in. the. present price of this market would be. important to understand or useful to understand. the only change between this. code here and this one up here other. than we don't specify the timeframe.

Which i perhaps ought to achieve this let me. reproduction this right here paste that during there and. change at present to. on. time-frame. so now this code is the image of our. first. block of code right here the sole change. is in place of sending out color from the. settings menu this here. which by the way is a decimal color no longer. a hex colour or a. rgb color it is a decimal colour not. sure why discord makes use of this in preference to. hex colorations. but you will need to appear up a web. converter maybe i will hyperlink one within the . description to transform your chosen. colour into a decimal value yet the sole. change with this block of code is we. assess if the current difference is triumphant. then we set it to bright green or else. we set it to vibrant crimson so if we have. effective volatility this will be a. green embed if we have destructive. volatility or bearish volatility it will.

Be a purple embed. then we use the alert operate to ship. this. json syntax to discord. and. that's it so finally the last thing i do. here is i create a custom table now this. is absolutely non-compulsory let me paste this. code in. here. and eliminate our plot close. this is absolutely non-obligatory i only did. this. so that i could um quickly and simply do. somewhat debugging with my text. formatting. for sending my indicators so now if i save. this script fingers crossed this would. collect without any blunders i with a bit of luck. haven't missed whatever. i spoke too soon. undeclared identifier content. an excessive amount of arguments ah because i removed. a parameter from our custom operate. here. and i forgot to update that now it. ought to assemble with none  mistakes there. we go. you will see that that our little customized desk. this is giving us only a bit of.

Data it is telling us what our. base foreign money is and what marketplace we are. on if we have been to visit for bitcoin for. example now it is announcing btc. and crypto if we have been to visit goold. it will be cfd. and xau usd. because this isn't a foreign exchange market or a. crypto marketplace. our marketplace variable. as you will discover right here. if it's foreign exchange or crypto then we circulate the. base forex to our industry variable. otherwise we simply reference the total. ticker so because this is not forex or. crypto. we are simply sending the entire ticker and. that'll apply to anything we uh search for. here so if i lookup apple to illustrate. this would say inventory and apple. and naturally you could set this. this alert up on apple and iit would work. simply similar to foreign exchange or anything like. that simply difference is you won't get. your little flag icon sent to discord. but of course if you wanted to you can.

search for an apple picture and positioned that into. your icon url and which will override. the image over on discord but besides. let's pass over the desk code surely. quickly this is not applicable to. the lesson. yet i'll cross over genuinely quickly first. component we do is set up a. table. with a position of center correct with one. row one column and a border width of 1. then we have a customized function right here. which fills the table fills the cell of. the table. so down here we assess is that this the last. bar on our chart. if so then we use the fill cell customized. function we move it our table id. we flow it 0 row identification 0 column id and then. our name which is marketplace. as you will see there. after which our textual content so this is market plus. after which our sim info symbol information dot. variety so this provides us our industry kind in. this situation that stock. after which we need to pass a colour a.

History colour for the table i simply. set mine to black with 0 transparency. and that i set the textual content color. to color.white i'll leave a link within the . video description to the weblog put up wherein. they introduced the discharge of this table. function and i've a few. guides there a few. example scripts that enable you to use. tables yet it is only a really easy. thanks to soon and visually exhibit certain. data from your script. in this actual case this was just. for debugging applications. simply so that i knew what my json code. turned into sending to discord anyway that is it. for our script. permit me wrap this up genuinely quickly. by using. i am going to add in the footer code in a. second yet let's simply experiment. this script. earlier than we move directly to doing that and. wrapping up this lesson. so let's create an alert on. um. let's go with us yen.

Why now not. uh we are at the 5  minute time-frame. let's go to a one minute time-frame so. that i could make this quick. click on upload alert. choose our script. depart it as any function alert name. make sure to paste in the right webhook. url so let me enable you try this. back. so right here we're on discord. i have to correct click my server go. server settings. integrations. cyber web hooks. and then click on my test spot. reproduction that webhook url. and then go back to trading view and. paste that url into our webhook url. parameter field here. you may call this  you desire you. can set any of this to however you want. you can notify your self that allows you to. all that's elective. now let's click on create and in five. seconds we must always get. an alert despatched. to my. exclusive sandbox channel in which i experiment. those varieties of things. there we go.

industry replace. despatched from buying and selling view you'll discover that. our webhook url's been our web bot sorry. has been overwritten with the parameters. we despatched in our script so it's not. referred to as experiment bot it is referred to as buying and selling view. it's got the buying and selling view icon right here and. all the data we would have liked to ship. it has got our worth. um the percentage we are on a one minute. timeframe so it did not circulate at all. sincerely. the rsi is 22.forty five in this industry and. we are on the single minute timeframe. awesome that is approximately it i do know  i variety of. rushed via this lesson but. the resource code will be within the . description back as always. so if you must simply rewatch this. lesson a couple of times in case you. if i rushed over anything you don't. particularly realize it. but it's particularly simple it's rather easy to. set this up and it's distinctly cool if you.

Have your possess discord server. or you are trying to set up your individual. preparation neighborhood. it is a genuinely cool feature to have. it's really certainly easy to establish and. as you'll find it simply posted a further. alert i bigger cross and disable the alert. or else i will get a bazillion. messages sent to my discord before i. you'll want to do that so i will bounce. over right this moment and delete that alert and. then i'm going to take a brief smash and. i am going to get back and we are able to add the. footer to this alert. adding the quote foreign money flag in. this case the japanese. flag symbol. to our discord message so i'll be right. back i must take a destroy have dinner. after which. i'll show you men how to try this all. right i'm returned uh i've converted my intellect. about adding the footer in latest. youtube lesson simply because this video.

Is already lengthy sufficient you can determine. out how to do this yourself if you. just research the json format for including a. footer to our embeds but it truly is what. the final product seems like on my. discord server the only element i must. change here is to convert these pips. into whole numbers yet you will see that. the.  icons are here now so we've the. euro. icon and the united states icon. in the header and footer which allows you. to identify which forex pairs are. which just a little less difficult for these of. you within the  panzer mastery course i'll. include an extended edition of this. lesson where i am going to show you how i added. this footer in yet for the youtube guys. looking thanks  for looking this video. i hope you found it fascinating make. guaranteed to hit the subscribe button in case you. did due to the fact i'll be again soon with new. classes on how to do some cool stuff.