Recency Bias With Streaks and Occurrence Frequency

Recency Bias With Streaks and Occurrence Frequency

YouTube Video

YouTube Video Transcript

[Music] hey this is David for big bits and in this video we are gonna talk about recency bias and using that idea to check for streaks and the frequency of certain occurrences in our indicators and most people probably think about recency bias and they think of that skewing your perception of what’s actually going on but what we are going to refer to as recency bias is placing a bias within our series of data on the most recent candles by looking for a frequent occurrence of some sort of event or require that there is at least a streak so there has to be so many events in a row and to do this I’m creating two inputs here for an indicator where you’re gonna require that there are X red candles three out of Y red candles this means we’re gonna look for three of four red candles in the past on the most recent candle so we’re gonna start here and we’re gonna look back four candles and see if three of the four were red and then we’re gonna do some other things as well I’m going to show you how we check for whether or not three of the last four candles were red and you can actually change this to work with other indicators so if you want to see how many of the last four candles were overbought on the RSI you could use the same approach and instead of looking at whether the candle is red or green you can look at whether or not the RSI was overbought so that is kind of the concept of what we’re working with here now I need to kind of go over the concept of how this is actually gonna work within the code itself now a lot of people are gonna be tempted to use boolean values when they create their indicators to save whether or not these conditions are true or false and that makes complete sense because when you’re talking about conditions you’re talking about a true or false statement so is the handle read that’s a true or false statement and also with is the candle green that is also true or false statement but I like to use float values because I can set those to either one or zero and one would be true in this case and you’ll see why that is in just a moment so the first thing we’re gonna do is create those variables and set them appropriately if the close was greater than they open the is green is equal to one and we’re gonna do that because we are gonna look back on our Y candles our four candles and we’re gonna get the sum of how many red candles there were that were green and their value sum by adding up the value 1 for every candle so if there were three candles that were green the sum of this value is uh excuse me the sum of is green will be three as well because each one had a value of one and we sum those all together you get three it’s a pretty simple concept and if you wanted to do a streak and you wanted to require that the last four had to be red then you would just set the x equal to the Y and that’s how you would do a streak but like I said in order to get the value of red candles over the last four candles now instead of having to go back and check whether the last four candles were true or false all we have to do is actually use the sum function and check for the value on is red so it’s gonna go back Y candles so it’s gonna go back four candles and it’s gonna get the total value of all of the is red so since all of the is red are gonna equal one this is just going to essentially check for how many occurrences there are and give you the total so if there are three candles and all of those candles have the value of is red equal to one your sum of all those is going to be three so you’re gonna have three candles it’s a little trick as opposed to having to type in to check specifically the previous candle and the one before that and the one before that this is a very easy way to just get the number of candles within the last so many number of candles then we are going to do something that we call a conditional check we’re going to check whether our recency bias is met that we came up with with our occurrence frequency the three or four and we’re going to check that our sum the number of red candles is greater than or equal then the number of red required and that is the x value not the Y and that’s going to be that’s what allows you to check for only three out of four and if you had this set to Y it would require the streak so just keep that in mind you’re requiring this number so you’re requiring that this number is greater than or equal to this one so if you set it to two you would only have to have two red candles here or it could have been three or four and that would have made the statement true now I’m gonna zoom out just a little bit I’m gonna change our code just a little bit I’m gonna show you how many red candles we actually have using this code once this saves you can see it’s now plotting the number of red candles out of the last four let’s actually zoom in and give you an example here and kind of come over here so it’s easier to see so let’s start right here out of the last four candles one two three four two were red and that’s actually the value that it shows us there and you can see that right here okay when I hover over the correct bar it’s showing two then we move over the next one it’s still two out of four but it’s actually two different candles well one different candle you have the current candle the previous but the two before that word green and you can see as long as those two remain in the sequence of four candles it’ll remain two and the last one got dropped out there a new one was added in so it stayed it to there and let’s go all the way over here you can see this one actually had three of the last four candles as well as the next one so this works the way we expect it to so let’s actually now show you how many of those candles actually had their conditions met so we’re now plotting a yellow line which when it is at the value of one means that our condition is true so it means we do have three red candles and you can see zoom in here the red line here was three so every time we had three out of four candles red it actually did say that our condition was true and that our recency bias was actually met so that takes care of checking to see if our streak was actually met we don’t need to see how many numbers of candles were actually red or not so we’re going to take that out and we’re gonna go in and we’re gonna check to see if the current candle zoom in we’re gonna check to see if the current candle is green and our recency bias is met so not only are we going to require that three of the last four candles are green but the most recent one is I’m sorry three of the last four candles are red but we’re gonna require the most recent one is green and actually what we need to do is we need to require that it’s actually three out of the last five because if it was three or less for the most recent candle would always have to be green to be true so let’s change it to last three out of the five and we are going to be checking the current candle is green and three over the last five were red and that’s gonna be a nice green color on our chart so let’s say this there you go so on these two the candles are green and that’s exactly what we want we want the most recent candle to be green and we want three out of the last five candles to be red and that’s actually the case on both of these candles from here back you have these three candles and it’s also the same on the next one and they both happen to be green so the green line that condition is true on both of those so this is how we can require that the current candle is doing something and that we have an occurrence frequency met to a certain amount on the candles before that as well and you can actually go back and look at this over time and see how many times this actually happened and you can use this as part of your methods and your own indicators to find different frequencies like I mentioned earlier on in the video you can look to see how many times the RSI was overbought out of the last 5 10 20 50 candles whatever you want you can go back and check using the same exact logic to see how these things actually work and I’m actually going to remove that so now all we’re gonna see is it’s gonna show us one on here when that condition is met and of course there’s all kinds of other logic you can do on top of this but this whole video was just about showing you how to put a recency bias on the current candles by checking for certain conditions on the newest part of the time series so all of our data here that’s just occurring we want to see and put a bias on it based on what’s happened recently so that’s what I mean by recency bias within the indicator here and our occurrence frequency check and our streak checks as well so that’s gonna do it for this video if you like the video please like and follow on trading you like the video if you’re also watching this on YouTube this video will get placed on YouTube after it is placed on trading view and if you like the video while you’re on YouTube please go ahead and subscribe that helps a whole lot and I’d like to thank if you watch the video this far you would like to see other videos like this because I make a lot of videos like this including pon script tutorials so subscribe and you’ll get updates when I make new videos like that as well but that’s gonna be it for this video I’d like to thank all of you all for watching and have a great day [Music]

YouTube Video Description

< br/> ???? IMPORTANT LINKS BELOW ????

Recency Bias With Streaks and Occurrence Frequency: In this TradingView Pine Script Tutorial/TradingView Update, we discuss how to create a bias for recency in your indicators by creating logic that is super simple to check for streaks of certain conditions with certain lengths and to also check for certain occurances with a certain frequency within the last number of candles. With Pine Script it is very easy for even beginners to create their own indicators or strategies that have many other indicators within them. Once we have completed the script, we can see our results immediately and begin working with more functions, indicators, and strategies.

Social and other public profiles
? Website:
? Discord:
? Twitter:
? Facebook:

Referral links
? Buy, Sell and Trade Crypto on Binance.US with LOW fees:
?‍♂️ Want to buy crypto? Get $10 of bitcoin w/ your first purchase over $100:
? Sign up for a paid plan at TradingView and receive a $30 credit:
? Browse privately and get rewarded with Brave Browser:
? Receive bonus perks when purchasing Lightnite Game:

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.

#bitcoin #crypto #cryptocurrencies #tradingview #binance #binanceUS #coinbase

This channel focuses on Bitcoin, Ethereum, LiteCoin, Ripple, Link, Basic Attention Token and almost all cryptocurrencies that demand attention. Please like the video if you liked the video, and subscribe if you like these types of videos. David from BigBits is an experienced Software Engineer, but no one is perfect, If you find any issues with any of the open-source, free code, or code shown in videos please comment to let us know what to fix, we listen to our viewers!