write 20 words summary based on this youtube script without saying in this videoIn today’s video we are going to be dressing another question from someone in the Mastery course and this someone wanted to know how to adapt the regime filter to work on multiple time frames so if you’re not aware of what a regime filter is it’s covered in great detail In Andreas clanow’s fantastic book stocks on the Move highly recommend that book if you haven’t read it already it’s one of my favorite trading books same with Unholy Grails by Nick Raj he uses a market regime filter in his trading systems as well this approach is best Suited to stocks although it does seem to show promise in crypto and certain other markets if you’re creative with how you apply it but the general concept is that the market needs to be trading above a higher time frame moving average before you start taking trades on a Lower time frame so in this case we’re on spy we’re on the S P 500 market index we’re on the one hour time frame and this moving average here is a higher time frame EMA right now it’s set to four hours but we could set it all the Way up to one week and now you can see that it’s turning green when price is trading above this moving average and turns red when it is not the whole concept here originally is for long only stock market strategies to only trade when the wind is behind our back so when The market is trending upwards on those higher time frames and this script you see down here is the regime filter script adapted to show three different time frames so we’ve got the 240 minute time frame or the um four hour chart we have the daily Time frame and the weekly and if I hover over these labels on the end we can see the actual EMA value there so what is more effective than using one market regime filter not necessarily three but if one indicator is good then several must be even better now I’m joking a Little bit there because a lot of Traders do like to throw on a lot of indicators on their charts and it’s not helpful but in this particular case this Market regime Builder could be useful especially on Lower time frames so if we go down to like the 15 minute chart here And you would adjust these higher time frame moving averages you could really make a simple rules-based objective method for determining your directional bias for day trading you know sometimes it’s difficult to know which way to trade a market when you’re using just discretion but with an indicator like This it’s pretty pretty clear where the momentum is and which direction you should be trading in and as a little bonus at the end of this lesson I’ve implemented this new Pine logging feature we open up the pine logs will actually tell us how often the market Trades above all of these higher time frame moving averages so if we go to the one hour chart again you can see we have a 54 chance that a bar will trade on this time frame this one hour time frame we have a 54 chance that the regime Filters will all be green what that tells us is that the market likes to Trend upwards at least on this one hour time frame and at least since 2009 until today which is a decent sample size by the way we have 20 000 one hour bars that we’re analyzing here to get these Numbers so yeah interesting script here let’s break down the source code uh the source code is not particularly complex and hopefully you guys find it interesting so let’s open up the source code here and break down everything so I’ve already written out the code obviously to save time the first thing We’re doing is getting our user inputs so we have three time frames here we have a moving average length which is 20 by default now this isn’t trading advice but obviously depending on the time frame you’re trading these numbers will matter a lot so on a lower time frame You would want these higher time frame moving averages to be a lot closer to your trading time frame so if you’re trading a five minute chart you might want the 30 minute hourly and and four hour time frames for example you want the regime filter to be more sensitive To short-term momentum if you’re trading a short-term time frame and if you’re trading a higher time frame like the four hour or daily you might want this to be the daily one week in one month or something like that same with the moving average length the lower the time frame Typically the lower you probably want this number to be the higher the time frame you might want to extend it to 50 100 or even 200 not 1200 that’s probably a bit too much the next input is our market so this is the market we’re referencing to get all of these EMA Values you could get rid of this input and simply pass in the Sim info dot ticker ID into all of these security function calls and then you would just retrieve all of the market information for the market that you’ve loaded onto your chart but the whole point of this Regime filter in its original conception is to trade it on things like individual stocks if I go to S P 500 here and we jump on to what looks interesting Netflix now we are plotting the s p 500s regime filters over the Netflix stock chart and so what this will tell us is When the broader Market is moving upwards um you can see that the regime filter Now does not match the price action I have on my chart because this information down here is referencing the S P 500 while all of this including this higher time frame moving average is referencing Netflix’s price action and How you would typically use this regime filter is to only trade these members of the regime filter universe so in this case members of the S P 500 when the S P 500 is trending upwards if you were to use this on crypto you’d probably want to reference Bitcoin on altcoins and if You’re using it on something like Forex maybe you want to reference the dollar Index when you’re trading dollar denominated pairs like euro dollar dollar Yen Etc but anyway let’s go back to the S P 500 for now and finish breaking down the source code so before we get any of this information we’re Creating a custom security function that does not repaint so I’ve gone over repainting many times in the course and on my YouTube channel so go back and check those videos out if you are still uncomfortable with repainting but basically including this code here these little historical operator checks this Check is checking the real time price information the real-time bar if the real-time bar is currently a real-time bar not a historical bar we reference that bar otherwise if it is a historical bar we reference the previous bar now don’t ask me why this expression eliminates repainting it’s just Blackmagic that the training view developers have decided to implement on this particular function and it works so that’s all I know and so when you’re using the security function make sure to include this code expression if you do not want your script to act differently on real-time price movements compared to Historical price movements that’s a big problem with uh strategy scripts in particular if your script does not perform the same on historical data as it does in real time then you’re obviously getting dodgy back testing results which can lead to the development of systems that aren’t profitable but look profitable on paper Anyway you don’t need to have this security function this Custom Security function I just implemented this into the script because it makes these lines of code a lot easier to read otherwise we would have…
write 2100 words and add headings article based on this youtube script use 20 words in a sentence in maximum 25% of sentencesIn today’s video we are going to be dressing another question from someone in the Mastery course and this someone wanted to know how to adapt the regime filter to work on multiple time frames so if you’re not aware of what a regime filter is it’s covered in great detail In Andreas clanow’s fantastic book stocks on the Move highly recommend that book if you haven’t read it already it’s one of my favorite trading books same with Unholy Grails by Nick Raj he uses a market regime filter in his trading systems as well this approach is best Suited to stocks although it does seem to show promise in crypto and certain other markets if you’re creative with how you apply it but the general concept is that the market needs to be trading above a higher time frame moving average before you start taking trades on a Lower time frame so in this case we’re on spy we’re on the S P 500 market index we’re on the one hour time frame and this moving average here is a higher time frame EMA right now it’s set to four hours but we could set it all the Way up to one week and now you can see that it’s turning green when price is trading above this moving average and turns red when it is not the whole concept here originally is for long only stock market strategies to only trade when the wind is behind our back so when The market is trending upwards on those higher time frames and this script you see down here is the regime filter script adapted to show three different time frames so we’ve got the 240 minute time frame or the um four hour chart we have the daily Time frame and the weekly and if I hover over these labels on the end we can see the actual EMA value there so what is more effective than using one market regime filter not necessarily three but if one indicator is good then several must be even better now I’m joking a Little bit there because a lot of Traders do like to throw on a lot of indicators on their charts and it’s not helpful but in this particular case this Market regime Builder could be useful especially on Lower time frames so if we go down to like the 15 minute chart here And you would adjust these higher time frame moving averages you could really make a simple rules-based objective method for determining your directional bias for day trading you know sometimes it’s difficult to know which way to trade a market when you’re using just discretion but with an indicator like This it’s pretty pretty clear where the momentum is and which direction you should be trading in and as a little bonus at the end of this lesson I’ve implemented this new Pine logging feature we open up the pine logs will actually tell us how often the market Trades above all of these higher time frame moving averages so if we go to the one hour chart again you can see we have a 54 chance that a bar will trade on this time frame this one hour time frame we have a 54 chance that the regime Filters will all be green what that tells us is that the market likes to Trend upwards at least on this one hour time frame and at least since 2009 until today which is a decent sample size by the way we have 20 000 one hour bars that we’re analyzing here to get these Numbers so yeah interesting script here let’s break down the source code uh the source code is not particularly complex and hopefully you guys find it interesting so let’s open up the source code here and break down everything so I’ve already written out the code obviously to save time the first thing We’re doing is getting our user inputs so we have three time frames here we have a moving average length which is 20 by default now this isn’t trading advice but obviously depending on the time frame you’re trading these numbers will matter a lot so on a lower time frame You would want these higher time frame moving averages to be a lot closer to your trading time frame so if you’re trading a five minute chart you might want the 30 minute hourly and and four hour time frames for example you want the regime filter to be more sensitive To short-term momentum if you’re trading a short-term time frame and if you’re trading a higher time frame like the four hour or daily you might want this to be the daily one week in one month or something like that same with the moving average length the lower the time frame Typically the lower you probably want this number to be the higher the time frame you might want to extend it to 50 100 or even 200 not 1200 that’s probably a bit too much the next input is our market so this is the market we’re referencing to get all of these EMA Values you could get rid of this input and simply pass in the Sim info dot ticker ID into all of these security function calls and then you would just retrieve all of the market information for the market that you’ve loaded onto your chart but the whole point of this Regime filter in its original conception is to trade it on things like individual stocks if I go to S P 500 here and we jump on to what looks interesting Netflix now we are plotting the s p 500s regime filters over the Netflix stock chart and so what this will tell us is When the broader Market is moving upwards um you can see that the regime filter Now does not match the price action I have on my chart because this information down here is referencing the S P 500 while all of this including this higher time frame moving average is referencing Netflix’s price action and How you would typically use this regime filter is to only trade these members of the regime filter universe so in this case members of the S P 500 when the S P 500 is trending upwards if you were to use this on crypto you’d probably want to reference Bitcoin on altcoins and if You’re using it on something like Forex maybe you want to reference the dollar Index when you’re trading dollar denominated pairs like euro dollar dollar Yen Etc but anyway let’s go back to the S P 500 for now and finish breaking down the source code so before we get any of this information we’re Creating a custom security function that does not repaint so I’ve gone over repainting many times in the course and on my YouTube channel so go back and check those videos out if you are still uncomfortable with repainting but basically including this code here these little historical operator checks this Check is checking the real time price information the real-time bar if the real-time bar is currently a real-time bar not a historical bar we reference that bar otherwise if it is a historical bar we reference the previous bar now don’t ask me why this expression eliminates repainting it’s just Blackmagic that the training view developers have decided to implement on this particular function and it works so that’s all I know and so when you’re using the security function make sure to include this code expression if you do not want your script to act differently on real-time price movements compared to Historical price movements that’s a big problem with uh strategy scripts in particular if your script does not perform the same on historical data as it does in real time then you’re obviously getting dodgy back testing results which can lead to the development of systems that aren’t profitable but look profitable on paper Anyway you don’t need to have this security function this Custom Security function I just implemented this into the script because it makes these lines of code…