TradingView
A_Traders_Edge
19 nov. 2021 07:57

Scanner/Screener of Over 40 Coins Per Script 

NEM / TetherKuCoin

Description

I am very scatter-brained by nature and sporadic in my thought processes but if these benefit the community and ya'll ask for more perhaps I will get better and even out a tad....probably not....but you never know. Firstly, allow me to apologize to all the vet/more sophisticated coders out there whose eyes and brains might just be overly taxed due to my poor coding structure. Im just getting started for the first time in ANY sort of coding...so cut me a little slack. Also, if anyone sees any mistakes or the functionality is not as I proclaimed, PLEASE do let me know. In these past 12mo of me learning my 1st coding language (Pinescript) I would say that I have been intently focused on creating all types/sorts of scanners/screeners. Ive always hoped to be a benefit to the community as I was always SO grateful to those who have come before me that have led me to the little bit of progress I have made with Pinescript. This script is not necessarily something that should be traded with as it is just a thrown together example showing a scanner/screener whose results produce plot outputs (ie, Rate of Change / oscillators as well / etc) and how they can be used in the alert system so that only 1 alert has to be set per iteration of the script but more importantly how to use/scan/screen with over 40 coins per script. My intent is not to trick anyone here. So to be PERFECTLY CLEAR, more than 40 coins CAN in fact be screened/scanned from one script (here I am doing all of KUCOIN's Margin Coins...72 total I look at)...BUT...(heres the catch) it must be added to the chart however many times EQUAL to the amount of "sets" you have in your script. (Heres the limitation by TV) There cannot be more than 40 coins in each "set". The less coins you have per set, the quicker the script will startup and run, thus, the quicker alerts will be received if automating the process. Though, if you only have the free plan and can only have MAX 3 indicators per chart then the MAX you can screen at a time is 120 coins if you use 40 coins per set. So, this is the first one I would like to introduce. For this one your screener/scanner must be using some sort of plots as output that is being screened for. (original inspiration of ALL my variations mainly come from @QuantNomad, @Daveatt, and @LonesomeTheBlue (and a few others I may be forgetting at the moment). Thanks for the inspiration through countless publications that ya'll have created for us in the community.

Some of my variations are more complex/elegant than others but there are MANY very different ones that I would like to share with the community. If you leave a comment and wonder why I have not responded but did so to every comment around yours...see if you are one of the individuals in this next few sentences...and if you are then perhaps someone else would like to waste their time responding to your comment...but basically, if you don't want to spend the time helping yourself by reading the title, description section, AND the comments section (at least scanning them) then I am MOST DEFINITELY not going to help you down your path of destruction that is most likely soon to be your blown-up trading account. I was called a "masochist" after asking for guidance on if its worth the headache to publish anything on TV bc there will NO DOUBT be comments that'll make me wish I didn't (ie. someone CLEARLY not reading the description (or seemingly even the title sometimes) bc they make a comment that has been explicitly addressed, or someone asking to rebuild the code compatible for another charting software or whatnot, or how about those asking if it repaints (this one is almost always addressed in the comments section but I can understand this question more than others as Im only 1 yr into learning any sort of coding for the first time in the beginning I saw people ask on EVERY script about if it repainted and it was worrisome at the lest (esp bc I didn't even understand what it was not so long ago, or my favorite...what TF it works best on...these people CLEARLY need not be trading yet if your still asking questions as such...Ill end it there). Point being, Ive got some truly VERY useful scripts that I want to share and as long as these people don't make me regret doing so in the beginning, then whats mine...will soon be yours. Though, I will take a little time between the releases.
YOU GUYS (TV and its community) ARE AWESOME (most of you anyways ;)
MUCH LOVE,
ChasinAlts

(1) INPUTS
Here is where the "sets" come in. I am looking at all of KUCOIN's Margin Coins (72 of them at least) so am splitting them up into 3 sets/iterations and a copy of the script must be added equal to amount of "sets" you have here. This is the ONLY workaround I have found to be able to scan/screen with more than 40 coins per script (due to TV's limitation of 40 Security Calls per script) ***So for everyone saying it's impossible scan more than 40 Coins per scipt...it' MOST DEFINITELY possible....BUT ONLY by adding this script multiple times on the chart and selecting 1 of each of the "sets" in the script settings via the chart window. To save the much needed room you must push each iteration of the script into 1 window and merging the scales of each into 1 scale(ie. "Scale A") within the settings of the script name on the chart(3 horizontal dots)

(2) FUNCTION
(2.1) COLORIDs
This is just to set up all my Colors of plots which are being matched with their respective labels. I have a diff color for each of the 72 coins Im plotting so Im telling the function, "depending on which set of coins I select...give me this color out of the colors I input later into the function"

(2.2) TICKERID CONSTRUCTION
I construct the tickerID this way so that the labels on my plots have only the Coin's name vs the label having the (Exchange Name):(Coin Name)(Base Pair Name). If you are using more than 1 Base pair (ie. XRP/BTC and XRP/USDT and XRP/ETH) OR more than 1 Exchange OR want your plots to show MORE THAN just the Trading Coin's name, then the tickerID MUST BE constructed differently

(2.3) SECURITY CALL & PLOT OUTPUT VARIABLES
If using a Higher Time Frame in Security Call then it MUST BE adjusted to permit or dissallow repainting if you so wish (BEYOND THE SCOPE OF THIS PUBLICATION so Do Your Own Researh). If your MAIN LOGIC is more complex than simply using a TV built-in function), THEN it MUST BE built into its own function outside of this function and called on within the "expression" slot of this Security Call OR can also be built into this function and called on in the "expression" slot of this Security call (BEYOND THE SCOPE OF THIS PUB SO DYOR). FURTHERMORE...when you are using a series(ie high/low/close/open/hl2/etc) / bar_index / time / etc that will be specific to the Coin/tickerID, then they MUST BE explicitly used within the "expression" slot of the Security Function when calling on your Main Logic or else it will pull the series/time/bar_index/etc from the Coin that the Chart is presently on (BEYOND THE SCOPE OF THIS PUB SO DYOR)

(2.4) PLOT LABEL
This is the Plot's Label that will be next to the end of the plot on the LAST bar_index. ***Notice in the "text" slot of the label I have "_coin" (without the quotes obviously)...this is where have JUST the Coin's name comes into effect on the label vs the (Exchange Name):(Coin Name)(Base Pair Name) which looks MUCH cleaner

(2.5) ALERT LOGIC / ALERT LABEL
Your alert logic need not be as complex as this... I just wanted to create a decent enough timing for this system and wanted to simply print the labels displaying which coin produced the alert at the same time the alerts would go off. Alert is set up to Trigger Bullish when the ROC is below the Threshold and _chg > _chg[Xbarsback] X=length of bars inputted in "Rising/Falling Length" setting and vise versa for Bearish Alerts. If _chg plot only goes past threshold for a VERY few amount of bars NOT providing enough time for initial Alert to trigger, then alert/label triggers on crossing of threshold back towards 0(zero). ONLY 1 alert needs to be set per script to be able to scan ALL 72 of the coins as I have them in this script. Timing of Alert is inline with the name label printed past the thresholds.

(3) VARIABLES FROM MAIN FUNCTION
This is the tuple of the Main Function that outputs the variables from 3 lines up to be able to plot the lines and color them according to the colors on the labels. *** As of now, we CANNOT plot from within the function so MUST BE done this way to produce the variables and colors needed. The plots are the ONLY thing in this script that cannot be executed from within the function

(4) LINE PLOTS
ALL output variables from our Main Function are used here for the line plots

Commentaires
OutsourcE
I have 2 Q's,if i may...
1 - why there's a name of the ticker on which the script is plot on, in the alert message field?I think it's not necessary

2 - the logic for consecutive bars that are above/below the thresh, doesnt work and it fires alert soon as it crosses.
A_Traders_Edge
@OutsourcE, Can you rephrase 1 for me? and as far as 2, if you input for the alerts that you want them on every occurance (rather than upon candle close) that would potentially be making what you are describing happen. So youll want to hard code or select when setting the alert that you want the alert after candle close. Get back to me after if it still is occurring. But also, I did just quickly make this as a proof of concept and not as anything to be traded off of (as stated in the description. I might revisit it one day and make it better but have too many other great scripts that are more than just for a proof of concept to concentrate on at the moment). That being said, i tend to be a people pleaser so if you want something specific then please do state it. Regarding the first part of your previous message, check out my other scripts that are updated to v5 or you can also just select the 3 dots at the top right of the Pine Editor's tab and if you dont have any errors on the script and have saved it you can then select "Convert to v5" or something like that so it will do it for you automatically. For the last part of your previous message, are you looking for line plots to show (with RSI and many coins, that will get super messy but nonetheless is simple enough) or are you looking simply for the coins names to pop up on the screen and alert to trigger every time one goes into OB/OS territory (that will produce a LOT of alerts) or have something different in mind? More details will allow me to further assist you. Also, if your not sure what you want have a look at a few of the other scripts to get an idea of what you want to visually see and we can go from there. Cool?
OutsourcE
@chasinalts, "could you paraphrase 1..."

By this i mean, suppose you put this script on BTCUSDT ticker and the alert is triggered on DOGEUSDT, youll get a message like this: "your BTCUSDT alert is triggered." DOGEUSDT Bullish ROC Alert

Now i don't know if it's like that by default, but having "your BTCUSDT alert..." Is not necessary
A_Traders_Edge
@OutsourcE, Yea thats def strange bc mine dont show up like that. They simply show the msg. Maybe its a setting you have selected as you seem to be leaving the possibility open to.
OutsourcE
@chasinalts, thx, i fixed the xchange name it works as expected.next, what i need a Screener for is not just rsi,rsi is just a trigger for something else.and that something else is what i need alerts and screener for. Unfortunately, I'm not allowed to post screenshots et al, to make an inquiry precisely.

And i like this one of yours most.Its exactly what i was looking for , for a scanner.Thx for sharing it!
OutsourcE
@chasinalts, I've sent you a msg
OutsourcE
Hey, could you plz update it for bybit and v5?Im looking a scanner for simple rsi ob/os
Thx in advance!
A_Traders_Edge
@OutsourcE, On line 18 where it says "KUCOIN", replace that with the exchange you want and if the "quote" currency is something different on your exchange make sure to change "USDT" on line 18 to whatever quote currency the exchange uses....and of course change the "base" coin on lines 42-65 to the base coins you want to observe(XRP/SAND/RUNE/BCH/etc). I do though have a script that Im presently about to finish that you might like. I have an RCI version and also a RSI version (RCI is similar to RSI though wayyy smoother and a change in length setting for the RCI does something a lot different that RSI...and better than RSI in my opinion). Look up RCI (Rank Correlation Index) in public library if not sure what Im talking about. Sorry...off on a tangent...so what the script does is it counts 1 point for every candle close where the RSI/RCI is OB/OS (overbought/oversold) and plots only the coin that has the highest OB/OS count within that "set" of coins thus allows you to see which coins are staying OB/OS for longer (as those are pumping/dumping more than the others at the time. Might publish it if it interests anyone.
Plus