Automated MACD Trading Strategy Secrets (Free MACD Day Trading Strategy For Tradingview)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on my name is dylan greg and welcome back to the trading view coding series where today we're going to be having a look at the popular macd trading strategies that we did look at in the last couple of videos so by the end of today you're going to be able to take these trading strategies automate them through training views so that you can test and validate that everything i have shown you is of course 100 correct but then second to that you can take these training strategies you can make your own tweaks or add your own parameters or your own indicators make your changes so that that way you can make these trading strategies your own so if you haven't watched my last two videos on the macd trading strategies then i would highly recommend that you watch those first because we did find a couple of really important insights so the first video what we did was we went through the popular macd trading strategies that i did find on youtube that a lot of people i would suspect are actually trading and they're trading the macd in a traditional sense and we did find that unfortunately well they kind of didn't work so we did get a few comments in the comments section of that video and that was to you know dylan if these trading strategies performed this bad then why don't we take the opposite signals of what these training strategies actually would normally do so in the second video and the follow-up video of that we actually tested this out and we did find that they actually worked and worked quite well so taking a contrarian approach and taking the opposite signals of what majority of the crowd has been doing might actually be a profitable way to trade so that's what we're going to be going through today we're first going to be going through the traditional way of trading the macd indicator using these uh trading strategies that we did go through in the first video but then of course i'm going to show you how to take the opposite signals so that way you can test and validate any trading strategy that you see on the internet and even test what happens if the opposite signal might look profitable so without further ado let's have a look at the computer so the first thing we need to do and if you're familiar with this you would already have these uh these files but if you don't then this is what you're going to need so you're going to need to go over to my discord link in description you're going to have to go through the resources for dillon tab which is this one over here under the announcements scroll to the 13th of the 5th 2021 and then download this template text here so this is the template for trading view that we're going to be going through so if you want to follow along then i would recommend of course getting this template and then the next thing is the excel spreadsheet or the strategy tester spreadsheet and i think the most updated version is this one here which is version nine and that is the excel template spreadsheet that i do use currently using trading view and of course it's down here for you to use and if you've been following along in this coding series you would be very very familiar with this spreadsheet here if you're not familiar with this and if you are a little bit behind then i would highly recommend looking at some of my older videos so that way you can get up to speed with coding in trading view and coding in pinescript using some of the resources in my discord so the next thing this is of course my youtube channel watch these two videos to get up to speed on the macd trading strategy because we did go through a lot of data and a lot of different trading strategies to understand the macd indicator and these macd trading strategies that we're going to be going through today the first video of course is this one here and then this follow-up video is this one here and we did find 10x roi it's it's not cap so we tested it out and we did see that taking opposite signals looks very very promising more promising than taking the traditional macd signals so trading view let's actually start coding this trading strategy so i'm on the euro swiss just for now on the 30 minute time frame what i'm going to do is i'm going to add in the macd and if you've been following on you would have known that we're also using pivot high and low indicator and i'm going to change this to 5. five please and the last thing we need is an ema [Music] um i got lost there and for this trading strategy we're going to be using a let's say 200 i think it was 200. so the trading strategy that we're going to be coding up first is the trading strategy i think they were more or less very similar but the trading strategy from trading rush using the macd indicator and i think actually i think trading rush was using a 100 i actually don't remember i think it was a 200 actually i'm sorry but i actually forgot whether it's 200 or 100 doesn't matter you can make the changes but uh we're going to be using the macd indicator on default settings we're going to be using an ema 200 100 or whatever you want it's up to you and we're going to be using the pivot high low and the pivot high low indicator set to a period of five is where we're actually going to be setting our stop loss and then from there our take profit so just a recap of what the trading strategy is when there's a bullish macd cross we're going to go long but only when uh price is above the exponential moving average and that is going to be a long signal we're going to be taking our stop loss from the previous swing low and then we're going to be setting our profit target to 1.5 the distance from our stop loss and that's going to be our profit target the opposites of course for shorts now that is trading russia's uh straight trading strategy but then second to that of course if you followed along with the video you would have seen that we also need to code in the location of where the macd cross signal happens so we're only going to be taking long and short trades on a macd cross uh well full for longs the macd cross has to be below the zero line and for shorts the macd cross has to be above the zero line so if we look at the macd so over here would be a bullish cross over here will be a bearish cross uh but let's see like something like this over here where price crossed again we're not actually taking this trade if we did have of course all the signals because a bearish cross over here would actually be a false signal or say over here actually this is a better example a bearish cross under the zero line is something that we're not going to be doing so we're adding in another condition here where the cross of the macd for longs has to be below and the cross for shorts has to be above the zero line so that's pretty much the training strategy that was provided by not well data trader and of course trading rush but then after that we're actually going to be taking the opposite signals and we're going to see what happens if we do take the opposite signals and i'm going to be showing you this straight from trading view pine script and straight from the strategy tester so if you've downloaded the template from the discord it would be this over here and i would recommend actually watching some of my previous videos i think the no nonsense forex video was the one that i did go through in a bit of detail yes so if you want to get up to speed with what this does what this template does i would recommend going through to to this but i would suspect that most of you are actually very fluent now with coding in a trading view so you if you've been following along you would actually be well up to speed and you'll be following along in this video quite easily so let's just get straight into it now the first thing i'm going to do is change this name to macd trading strategy uh everything else we're going to start with a 50 000 account and our base currency is going to be the us dollar we're only using pyramiding one so we're only taking one trade at a time we're not taking multiple trades at once what i might do i might zoom in one more very nice awesome so all of this is just part of the template we don't need to worry about that what i'm actually going to be doing however is normally this template set up for people that use the daily chart so our date our back testing date range is quite long however for purposes of this video and for shorter time frames like the 30 minute what we're on today i'm going to be actually going through and changing these values so my back taste my back testing date range is going to start from the 1st of the 7th 2020 to the 1st of the 7th 2021 now this is of course an input variable so we can change this uh in the actual charts themselves but it's just easier to change it in here because that's what we're going to be using majority of the time anyway i don't have to worry about any of this stuff uh over here now i'm gonna actually have to change the location of this and the reason why i'm changing the location of this is because we're actually not using money management atr we're actually using uh the pivot high and low for our money management and that is actually going to be down here so i'm not going to change this just yet i'll wait till we actually start coding the pivot high and low but just to note that we are going to be changing this a little bit because of course we're not using the atr all of this is relatively fine that's fine for now now the only thing that i'm going to change here is the exit so if you watched my video last week or the week before you would have seen that the way these training strategies are set up is that we're not exiting on a macd cross we're only exiting when there is a take profit or stop loss or we get a completely opposite signal so for example we need to exit on a take profit stop loss or if we're in a long trade we only exit when we get the opposite signal or a short trade so we're actually not exiting the trade if we get an opposite macd cross at all so i'm just going to comment these two out down the bottom here and what this comment was before was if we were exiting using the macd cross or indicator one is how it's set up and indicator one's always going to be our trigger that's how the template is set up so comment these out and you're good to go so that's all the changes that we're going to do first what i'm going to do is hit save and then that should have no errors but it's of course not going to do anything very good and you can change the name to whatever you want to change it to as well i've just got it there's a copy but anyway if you've been following along you would know what we have to do here we have to copy over the indicator codes to our actual code itself so first thing just so we keep it is i'm going to add this to the chart it's going to do nothing but we can see it over here so it's added to chart and it's down over here the next thing i am going to do is i am going to get the macd or import it and i'm going to copy the macd and the way i got the macd was i actually hovered over the macd and then got the source code anyway i'm going to go back to the source code of our trading strategy here open the source code back up go to indicator 1 and now indicator 1 is always going to be the trigger and the trigger is the macd crossover and i've just pasted it in there so i'm going to call it macd now of course we're going to have to be going through this code but i think it's relatively fine we don't really need to understand a whole lot of this uh all these colors actually we don't need all these colors plot colors okay so the macd indicator because it's not an on chart indicator the macd is actually plotted down here we don't actually need any of these plot functions because the plot functions are only used for when trading indicators are on the actual charts themselves but because this is in its own window i've got it set down here so if it's set down there we don't need the plot functions i can delete that and we don't need the inputs for the colors because of course we're not actually plotting anything so we don't need any color inputs now the last thing we're going to need yeah that looks right the calculating the histogram let's just leave that in there cool now just to test to make sure that nothing is broken i'm going to cross this off and to chart so i've just cancelled the old one i'm adding this trading strategy to the chart and see it compiled so it loaded up that's good now the first thing i'm going to do is add our conditions in so the first thing i'm going to do is our trigger conditions are always going to be the crossover and now what i'm going to have to do is go to the indicator itself so when do we want to go long so if we're actually using the macd as a traditional uh i guess in the traditional way we want to go long when the blue line crosses above the orange line we want to go short when the blue line crosses below the orange line so that's going to be our first trigger or our first event so just to double check to make sure we know which is which i've just gone to the settings here i've gone to the style and we can see the macd line is the blue line and the signal line is the orange line so when the macd crosses above the orange line and that's a bullish cross or when the macd crosses below the orange line that is a bearish cross and again we can see that in the histogram as well but i'm going to be coding it using the the signal line and the macd line so i'm going to go back to here ooh no i don't want to do anything just yet so macd i can see macd here so macd was blue and signal was the other now to get the opposite signals i can just copy and paste that but instead of a crossover we're going to be using a cross under so we should actually now be getting signals but remember that this is set up using the atr as default at the moment which is not actually necessarily a bad thing it's actually something that i'm playing around with at the moment instead of using paper tire low i'm actually using atr instead however um you know you can do whatever you like i'm going to be showing you pivot high and low but you can code it up and make it whatever you want so anyway uh we got signals which is good so let's actually test out to make sure that we've got it the right way around it's going to look messy because we're taking every single signal we don't have any other signals and that's fine long signal we get the crossover here confirms the cross belongs on the next one and that's a bullish signal uh let's see if i can find long signal i want to find a short signal that's here we go short signal there we go that's short over here very nice now the next thing is actually going to be adding in the condition of the um where the location of the cross actually happens so i'm actually going to be adding that into a separate indicator spot it's not you can add it here but you can add it wherever you like it's up to you uh what i'm going to do is actually add it in a separate indicator spot so what i'm going to do is so that's going to be the macd this is going to be the ema indicator 3 is going to be the pivot high low and indicator 4 i'll just go macd location so i'm just going to put it over here and it's just going to be a condition it doesn't have to be an indicator it's just a condition and that condition is going to be the location of where the cross happens so we're only going to be taking longs when the crossover happens below the zero line of the histogram so in other words we can actually code this so macd being this macd here so macd is less than zero and the signal line is less than zero so that means that the macd line and the signal line has to be below the zero line of the histogram or it has to be below zero so then that way if both of these are below zero then of course if a cross happens it's going to have to happen below zero now the opposite is true for shorts macd has to be greater than zero and has to be greater than zero so shorts if a cross happens then of course this condition down here has to happen as well where the cross has to be located above the zero line or greater than zero so if the macd and the signal are both above zero then the cross happens there then that's all good and we can do a trade so that should make some changes to our training strategy so see here we've got minus 47 000. i'm gonna take this off the old one and then just add a new one on and there we go it made it a little bit better so minus 22 000 which is good and our trades would have gone down as well our percent profitable has increased too but that's because we're trading with a uh one to one point five uh reward risk so an inverse risk reward essentially uh no nonsense forks related of course so uh let me save that so that worked that compiled saved good so that's the first part of our trading strategy the next part is getting the ema which is i don't even need to look at that really um so what we're going to be doing i'll code this up just by hand so um ema period equals input uh what are we going 200 yeah we'll go 200 doesn't matter 100 200 i forget which one was which apologies but it doesn't matter you saw what happened to the trading strategies anyway uh so 200 the uh ema equals ema now which one is it i think it's closed price first so yeah so you see here the syntax ema bracket source so we need to put in the source and that's going to be the close so we're taking the ema of the closing price and then the length is going to be the ema input so close comma ema period and then i'm gonna do a plot function oh plot ema color equals color dot yellow cool so what i'm going to do i haven't put the in the uh conditions in yet what i'm going to do is just make sure that i can add this to the chart and really we should see a yellow line come across if i hide this there we go so notice here so i've got the ema as an indicator but because i've added it into the code itself and being an on chart indicator which is the exponential moving average we can see here that it's actually coded up in yellow as well so we're good now i've just taken that off i've still got pivot high low in there just for now but just to go back to the code we can see that it did not change anything to the amount of trades or the profits that we did make and that's because we haven't coded the conditions now the condition of course is going to be for long's close has to be greater than ema and for shorts close has to be less than ema so let's add this to chap [Music] i kind of didn't do anything to the profit but it did reduce our amount of trades by quite a lot which i mean is good so that's fine so that's the training strategy that we're looking at and that's good now a very very important one this pivot high and low so the pivot high and low this is where we're going to be setting our take profit and stop loss and this is where we're going to be using the swing high and swing low of the previous chart so what we're going to do is again take the source code so i've got pivot high low take the source code i'm going to copy this and then i'm going to go back to my one here and i'm going to put this in indicator number three now this is actually very very important because a lot of people actually like to use candle wicks or candle bodies to actually set their take profit and stop loss particularly when you're discretionary trading you want to try and find previous i guess support and resistance lines or lines where there might be i guess supply and demand so that's where the pivot high load indicator comes in and that's what we're going to be using today we're going to be using this so that way we can actually uh set our take profit and stop loss just like how i guess those trading strategies did go through on on youtube this is how they've done it we can set them using the candle wix of the previous i guess previous high or previous low so just going through this again i'm just going to delete this version 4 over here don't need that that's fine gr i'm not touching any of that i'm going to change these default values to 5 and the reason why i'm changing it from 10 to 5 is that i wanted something a bit more um what's the word a bit more recent so that way we're not setting our take profit or stop loss from a candle wick that's like ages away particularly if we're on a lower time frame price can move relatively quickly uh so we wanted to keep the period a little bit lower so that way it refreshes a bit quickly so if there's a new high in the previous five candles uh it would have said it and i would have confirmed that uh later on so i don't think this is that's not going to change anything which is good so i'm just going to test it add it to the chart but this is where it's a little bit more advanced cool we got no errors it's a little bit more advanced and we have to do a little bit of work here to actually understand this so what i've done to help understand well myself when actually doing it is actually plot the previous swing highs and swing lows on the charts that that way uh when a previous swing high or swing low happens we've got that value stored within the code so if we do get a signal we can refer back to that value and then set our stop loss or take profit then so it's a little bit tricky um to actually do with well i guess i guess you can't do it we need to actually store the value of the previous high in the previous low because what happens in the code now without going through it is once uh this value over here so this is the previous swing low for this particular location once this is confirmed it gets put on this candle but then there's nowhere to store it like there's nothing in the code to store it it's just shown on the chart and that's it same thing with the highs so what we're going to be doing is actually making a variable storing these values so that that way we've got the most recent swing high and swing low so if we get a signal we can refer back to these values if a new one gets printed like here we can update the old value with the new value so we're going to be doing that using a float variable so uh they've got here p h and p hell so high and low so pivot point higher pivot point low uh what we're going to be doing is going to be using those same values so pivot high but i'm going to be using a float so i'm going to denote it with f so pivot high f and that's going to equal float and a so the reason why we're doing a float is so the float will store the value and it's something that can be changed so if we do get a new signal or a new sorry not a new signal but a new pivot high we can actually uh change that float uh so that that way or change that value so that way we've got the most recent float variable or pivot high variable for this example and if you've been following along with my coding series particularly in the no nonsense forex coding series you would know that that becomes very very important down over here and that's uh that's how we store the values so we're going to be using a very similar thing if not actually not well actually the same thing um so the float so we've got an initial value of the float as uh 0 or na however we want to actually give it that's the wrong one we actually want to give it uh i guess a signal so uh when it when we get a new pivot high then it stores the value if it if we don't get a new pivot higher then the value stays the same so that's what we're going to be doing so if uh the first thing we want to do if uh if it's in a pivot high um which means if there's no pivot high then uh pivot high f but the one before else pivot high so basically what this is saying is uh while looking at this code and what uh what what this code is pretty much saying is uh the this pivot high value or ph value here is only going to be a value when there actually is a new pivot high if there isn't a new pivot high then the value is actually going to be n a so basically what this code is saying over here is if there is no pivot high then we want the pivot high float which is this float variable here to be the previous value so this is what the the minus one is or sorry the the the one in the brackets so that's just getting the value from the previous candle so that means if they're so basically this together means if there is no new pivot high then get the value from the previous pivot high of the float however if there is a new pivot high so which means this condition is not true and then skips to this so then that way pivot high float equals the new pivot high so if that sound sounded confusing then i would highly recommend actually trying to understand what the float value is go back through some of my older videos try to understand this a little bit more because actually understanding this is very very important when it comes to particularly storing values so i'm actually going to do the same thing for pivot lows float pivot low float if pivot low is n a then take the previous pivot low else pivot low now last thing i want to do is actually plot this just so we have a visual representation of what this actually does so i want to plot pivot high low float color equals color.blue pivot high sorry pivot low float color orange perfect so i think that should be good now i'm going to hide this i'm going to hide that i'm going to add the chart no errors it's thinking it's very good here we go sorry ew ew i don't like that don't know sorry i'm gonna change this to white just so it's a bit easier to see because the yellow and orange looks very hard to see i don't know why i just didn't do that okay that's a bit better so we can see here we can see here that actually what i'll do is put the pivot high low so because the pivot higher low is on a period of five uh that means it takes five candles to confirm whether a new uh swing high or swing low actually is confirmed so there is a five bar delay so that's where we can see here that for this example if we had a long example or something happen here our pivot high low point would be on this confirmation point here which is 1.0964 and which is good like i don't mind like that's good because as an algo trader you want well as any trader you want confirmation because if you're taking or trying to confirm something like within here and you get a signal here you actually can't confirm that that's why you need a few candle confirmation that's why i've put it to five i think 10 is probably a bit too much but i think pivot higher five is um a period of five is actually pretty good to confirm something just like here we can see here after five candles or so that this is confirmed so then we get uh the new high here so the old pivot high which was this value here gets replaced uh once it confirms this one here and then it gets put up here what i'll do is actually i'll go through the replay feature and we can see oh this is too quick now i did get a question while we're going through this um by somebody that says isn't this a repainter if you're following no nothing's forex you would know what a repainter and no i don't think this is a repainter it's just got a five bar uh lag to it so there's a difference between a repainter and a lag this one has a lag so we can see here that when we got this trading signal well at the point of this trading signal we would actually put our stop loss at this swing low over here but remember we haven't actually coded in that just yet we actually are going to code that in just now over here so so that orange line here or sorry that red line here should match up with that orange line so that's the goal and then our take profit is going to be 1.5 the distance of that so very good i'm just going to cancel that replay function now i've lost everything here i am i'm back so what i'm actually going to do is i don't need this pivot high low anymore very nice now if you're sick of these blue and orange line by the way you can actually go into the styling just remove it but just for testing purposes i'm going to leave that on there for now now unlike the other indicators this is not necessarily it's not necessarily a confirmation tool the pivot high low we're just using it for take prop and stop loss however just for safety what i'm going to do is actually add in a second um a second filter here so basically um if there is any errors particularly when we're going to be taking the opposite signals there's going to be errors um we want to safeguard from those errors so basically the way to safeguard from that is well that error that i'm going to show you is that i want to put a condition where we're only going to be taking long trades uh if the close happens above the above the uh pivot low so for example of course we're going long so if we're going long we need our pivot load to be below the price and for shorts for short we're going to need our our pivot high to be above the close price so if the closes here of course we want pivot high to be above that so that way when we're going short of course we got room to actually uh go short in some cases of course using the pivot high low system if the price hasn't confirmed a previous high sometimes you might get a situation where for example if we're going short uh the price might actually when the price does cross the price might actually be above the actual pivot high itself and so that way uh your stop loss is actually above price for a short and so that's going to be an error so the way to prevent that error close so the close has to be greater than the pivot low belongs close has to be greater than pivot high oh not hf for shorts now that as i mentioned that's going to be the case a lot if we're taking opposite signals so that's a good way to work around it shouldn't have really done much or anything at all here because i think if if that does happen then you would have got we would have got error error marks or error comments in the strategy tester but anyway and that's just a good way to uh make sure that our stop-loss is always at the right location either below price uh for longs or above price for shorts so the fun part our money management so this is a very very important part of this trading strategy and that's going to be to actually set our money management now as i mentioned we're going to have to move the location of where our money management is on this template so at the moment our money management is above here uh but we're going to be using the pivot high low so the way the coding works of course it's like reading a book it goes from top to bottom we can't put any pivot high low commands in here because the pivot high low indicator itself is actually not defined above it so we're actually going to have to move the whole atr or the money management section i'm going to cut this um i'm going to cut that now actually go all the way down just past indicator 6 but before the entry conditions and i'm going to paste out money management and it's probably a better spot to be honest to have than actually at the top but anyway so let's go through our money management so this is actually going to be uh pivot pivot high low now we're still going to be risking two percent risk per trade but as we've seen uh you might want to reduce that risk depending on your risk tolerance and your drawdown requirements of your trading strategy uh atr inputs i'm just going to check that to enter inputs now we don't need an atr length we don't need an atr function and we don't need this atr value here as well so i've just gotten rid of everything that has anything to do with atr now what we're going to need instead of atr actually maybe i'll go back it might be a bit easier this one i don't need sorry okay so i've kept this instead so i've got atr equals trunk hit length but i don't actually need that okay okay very nice so instead of atr uh we're going to be putting in what we're going to be putting in let's call it risk risk oh this is embarrassing risk dollar so we're going to be putting in risk dollar and uh what we're going to be doing is what we're going to be doing is actually using the pivot high low for our risk dollar so this is where uh it gets a little i suppose well not not difficult but you have to understand this so i want to put in well let's just have a look at highs so let's just say we get a high crossover or sorry a long crossover so let's say we get a long crossover here so that's our trigger so i'm actually going to put this condition down over here indicator one so i'm going to put an if statement or a question statement so if there is a long crossover what do we want to do so we want to get the close so the closing price and then minus the pivot high no sorry pivot low float value and the pivot low float value is going to be this value here so the orange line so if i go back to the chart yeah here let's just look at this example every time we want to go long so if there is a long trade for example we want to actually take the uh the the orange line or the pivot low float value which is this pivot low down here and that's where we're going to put our stop loss so at this pivot low value and so over here so close minus pivot low now else so if we get the opposite signal indicator one short we want to take the pivot now we can't take the we can't take i mean we can take the absolute but we need to take the close minus the pivot low sorry the pivot high let's find sure a clear short a nice a nice short please here we go here's a short example we want to be taking the the distance between the blue line and the close so we want to be taking the pivot high oh no thanks pivot high float minus close else now make sure actually i don't need that make sure that you get this around the right way because if you do this around in the other way you're actually going to get a negative value so that means that your risk dollar is going to be a negative value which means you're going to be having a negative risk dollar value and uh it will give you uh an error so it can't be um it can't be a negative value if you want to safeguard against that abs you can take the absolute value of of this which means that just an absolute in math terms is just getting rid of the the minus sign so if it's a negative it's going to actually become a positive um so if you want to safeguard against any errors in here just take the absolute now we've got this new variable called risk dollar and this replaced our previous atr value so that can go in here so we don't need atr multiple loss times uh atr we just need risk dollar because it's the distance ah actually no i think i needed that uh because it's just the distance away uh between the previous high and the uh and the close we're not using uh a risk multiple of like 1.5 times atr or anything like that we're just taking um we're just taking the distance and the distance is already calculated using risk dollar so uh that means we don't actually need atr multiple loss this value here and that's it atr multiple profit that stays uh well that's actually going to be well i should say let's just so that's the first part the second part now is uh is adding in the uh 1.5 times the distance or 1.5 times the risk dollar for example here so at the moment i've already got atr profit uh over here i'm actually just going to change this to just multi multiple of the profit um and then that can be i'm just taking the reference out of atr but this is going to be 1.5 so we're going to be setting our take profit target which is basically what this is going to do set our take profit target at 1.5 times the distance of our risk dollar now where that happens is not at submit orders um oh no okay i'm gonna have to come back okay i'm gonna have to come back but anyway all right so the last thing i'm gonna have to do is actually change the uh values over here where it does say uh entry atr and we do have this atr multiple uh loss and multiple profits so these references to the atr of course we don't want so as i mentioned we don't actually need atr multiple loss i'm taking that out and this atr multiple profit we just changed to multiple profit uh entry atr is referred to up here uh where it does say uh entry atr uh in this section over here now all this section does is it stores again float variables it stores the values of the acr and the price now again we're not using the atr we're actually using risk dollar so uh where it's got atr i'm just going to change it to risk dollar so entry atr equals blah blah blah blah blah blah blah atr risk dollar entry atr true risk dollar so that way that should be good that's fine just lining it up it's ocd things you know there we go so i've taken out the references of well actually not here entry atr restore and basically all this is doing all this says is uh so the end loss so the amount that you're going to be losing is going to be the value of the entry risk dollar and the end profit is going to be the value of the entry risk dollar times the multiple profit and that multiple profit is going to be 1.5 so it's going to be 1.5 the distance of how much we're actually going to be losing so that means we're going to have a 1.5 to 1 uh reward risk ratio so i'll add this to the chart very nice let's see what it's done it's done something i'm going to have a look at the chart itself so here's that short so this short example over here has said okay what was the previous uh swing high and it happened to be this value now it didn't confirm this point up here the previous value was this swing high here so this was the point it confirmed oops that was the the point it confirmed so then uh it did set the swing oh sorry the stop loss over here and we can see that there take profit happened to be down here and this one happened to be a profit now let's have a look at our other indicators okay so we did get a bearish crossover above the zero line that's good and i'm assuming price is below the moving average so that's good let's have a look at the longs that's another short shorts shorts shorts get some nice short oh let's have a look at this short i guess it's quickly again it didn't confirm here but the previous swing high would have been confirmed at that point there or it might have been the other wick there we go so that was the previous swing high at that point there it didn't confirm this one here it confirmed it after the signal but that's okay it happened to be a profit that's fine if it did confirm out here then it's take profit would actually been down here and it would have confirmed eventually a loss so that one happened to work quite well here's a long example that happens to be a loser but okay so price did go long we can see we got a cross over here so there was a bullish crossover uh but only briefly but that's okay because we are of course disciplined traders we're using an algo uh we're still going to go long here because we don't know what's going to happen in the future and that's very very important especially when we did go through some of the reasons behind why manually back testing might be difficult and going through what some of the videos of the previous uh i guess people testing these training strategies did go through they were using hindsight back testing so i won't go into that now but anyway this here previous swing low gets confirmed the orange line moves up once it's confirmed we got a signal stop loss is taken here take profit is up here the one thing i didn't do is actually measure out one to one point five wrist reward what happened magnet tool please stop oh my gosh okay so this is our take profit our stop loss is this there we go and we got 1.5 to 1 risk reward or reward risk ratio which is really good so that means the code is working so that's the code done now this was i believe data traders or well data trader or trading russia's trading strategy and that's fine um however we did see that this training strategy did not happen to perform well at all this is uh of course minus 30 000 and this is just on one currency pair i'm just going to scroll through a couple negative negative negative negative that one happens to be a profit but it doesn't outweigh the negatives and i think this one was one of those training strategies where we did find it did blow up our account i'm just randomly going through this but you get the point anyway now what happens if we take the opposite signal so this is the part that a lot of you i'm sure would probably be waiting for uh we're gonna be coding in the opposite signals and i mean it's pretty much all done for us uh we just need to change a couple of things so let's start from the top so indicator one so instead of going uh cross long uh or cross over we're going to be going the opposite signal so an easy way to do the opposite signals is i'm just going to change this so instead of going long we're going short instead of going short we're going long so i've just changed these around so indicator 1 long was previously first that's now short and vice versa ema short long so now we're taking uh short trades when price is above the ema we're taking uh long trades uh when prices below the ema so again the reverse now this doesn't change so remember stop loss take profit is always going to be uh the same condition i mean it has to be because i guess uh for your lungs uh the clothes always has to be above your stop-loss level and this is this uh this pivot low level uh close always has to be above uh sorry for shorts clothes always has to be less than the pivot high if it's the other way around then you're getting errors so this does not change and remember that and that's why taking the opposite signals on uh i guess uh any trading strategy would not necessarily necessarily be uh completely inverse inversely proportional to each other and that is because your stop loss and take profit is actually um is actually going to be i guess somewhat the same but the same location and it's going to be all different so that means because they're going to be our stop loss and take profit is going to be the same uh or within the same location our one to one point five risk reward is also going to be the same now for this one you can choose to actually um i guess change this around as well i mean you probably should however i'm actually going to take this out now the reason why i'm taking these these conditions out is because uh data trader and this is the trading strategy i tested in the second video did not actually have the location of the trading crossover in their trading strategy so i'm actually going to comment this condition out however feel free to uh put it in or not put it in uh depending on what what you like now if um if you watched the last video you would know um know the reasonings why but this is it here so let's have a look previously minus thirty thousand with 149 trades win loss ratio was well 30 i've changed the conditions let's see what the opposite signals do everything else the same 40 bags 40 bags difference just by taking the opposite signals we've got a 50 win rate profit factor 1.2 which is okay but we got a much much better trading strategy just by using this one currency pair forty four thousand dollars so just by taking the opposite signals the difference between the two uh thirty thousand dollars forty four so seventy thousand dollars difference between the two and that's just taking the opposite signals of what these trading strategies actually do and this is going the the opposite way now let's have a look at some of the trading the trades [Music] um wait did i go too far i know i haven't gone far far enough that is why okay let's have a look at this so we got a long crossover here but we went short and that happened to be a profit uh we had another signal here we had a bit of a chop here and that again um that's something that we did talk about actually in the past couple of videos so you can try to adjust this play with this a little bit to try and get some of these choppy out uh this one actually happened to be a prophet uh but there you go i think it was a problem was it a profit yeah i was short there long yeah profit um here's another one bullish crossover short we went long [Music] oh yeah so price did go below the 100 200 or 100 i don't know which one it is 200 we got the 200 at the moment uh price did cross back over here we did go short but we did exit fairly early now this is something i wanted to show you actually and this is the problem with using pivot high low on this in my opinion now there's ways around this uh but i'll leave that up to you uh this is where i mentioned that i'm personally not using pivot hi-lo anymore i'm actually using atr and the reason why i'm doing this is because let's have a look at this and this is what happens when you use the opposite signals particularly uh when you're trying to use mean reversion i mean it's not a bad thing i guess this is kind of a mean reversion trading strategy we're taking the opposite signals and going against i guess the so-called trend uh but our stop losses are going to be fairly close which means i guess our take profit is going to be fairly close too but uh where's my line yeah good but we've taken a long trade here so when we take a long trade of course our crossover happened here it confirmed the cross on this candle we or this candle then we go long next we set our stop loss at the previous swing low which is this orange line here which came from this wick over here now have a look at this our stop-loss value is very very tight which means it didn't accommodate for this week now of course this can be good and bad because if it's a tight stop loss then we're going to have a relatively closer take profit so we're going to have more of a chance of a take profit so it might not be too bad but then once you start incorporating spreads and uh and fees and things like that having tight stop losses might be i guess not ideal uh if you want to um well once you start considering uh commissions and things like that based on your position size because of course the tighter stop loss your position size is going to be bigger when you're risking two percent risk per trade so you need to factor that in uh so i personally am actually looking into uh atr um instead of this so i know we've gone through the whole pivot high low thing but i give the atr a go that's what i'm doing at the moment it's more easier and it's more consistent in terms of position size compared to pivot high low but saying that just based on what we've got at the moment is still very profitable as we can see and how many trades do we have we've got 300 trades i think that i think that's still more trades than what the previous was it's good and see for these short examples our previous swing high is all the way up here so have a play around with it if you want to keep using the pivot high low i've also played around with actually um only taking trades that aren't uh as tight uh maybe you want a little bit of a a bigger range if it's too tight then you don't take the trade or if it's too big like this example you don't take the trade so you you're trading in between a range uh for your pivot high and low so you can do that or you can use an atr or a um a volatility adjusted uh risk reward parameter uh but saying that um just like this it looks profitable so this is uh the same trading strategy i believe if it's not a 200 ema it's a 100 i forget again i mentioned this stuff get which one it is um this is the same training strategy that i did go through in my uh 100 or 10 10 times video and what's really cool about this is you can of course change all the parameters on here let's just have a look at 100 relatively the same 200 yeah same thing very good what if you wanted to change your wrist parameters yeah one let's go one to one yeah see this is the power of coding you can do what you like and it's a lot of fun relatively quickly cool beans so uh again i'll just scroll through a couple of things just so i didn't cherry pick this chart oh that's nice actually a lot of winning pairs that's what we want to see like yeah there's a couple of losers of course oh that's huge 60 pants and again let's sheesh almost 70 there and this is what i like to see is the trading strategy actually is profitable on a lot of actually a lot of different pairs it's not just profitable on one pair and then the rest is like average or bad oh there you go that's all 28 pairs tested right there if you want anyone just want to use that there you go it's a little there well don't don't use it as a not financial advice please please please actually do the work that's the whole point of this video youtube channel and playlist series do the work uh because now don't don't even trust me don't even trust me don't even trust this code even though i did it live for you just then um don't don't trust it do it yourself and uh make your own changes uh changes understand the data because that is very very important um because of course uh you need to go through the charts as well in a bit more detail validate that this all works add in other things like adding your spreads and your commissions and things like that because of course there is a little bit of a bias here but adding all of those things in the strategy tester and you can do that all in training view which is really really cool commissions all of these different things have a play around with it it's completely up to you change the training strategies change the parameters change whatever but yeah it's all there the power is yours and that is a lot of fun so what a beautiful beautiful episode so i hope you can now watch this video and uh code this up yourself of course using the resources uh from my discord and then this video code it up yourself make sure that you validate it test that it works and do your other things like the commissions and the spreads and and the whatnot so that way uh when you get it to a stage that you're actually comfortable with and you're confirmed that it works for you and your beliefs and everything like that uh then that's great that of course is the goal of this uh training strategy and that's of course the the goal of you know coding this um using an automated and algorithmic approach to trading uh because of course that way you can actually test these training strategies with conviction with a high sample size and not rely on you know people on youtube that say you know 100 trades is is is all you need or you know i've tested this with 100 trades because as we've seen uh it didn't work the first version uh that we did scroll through taking the trading strategy the way that it should have been traded and the way that you know these people are showing it uh it's it didn't perform and so taking the opposite signals and what taking the opposite of what the majority are doing uh it did perform as we just demonstrated here so of course as i mentioned there's still further work to do especially for yourself you need to code this but then of course uh have confidence in it uh so i'll leave that up to you let me know how you go in the discord uh and in the comments section down below if you did enjoy this and you did learn something from it uh please please uh leave it a like and of course consider subscribing because this is something that i'm going to be frequently doing on this youtube channel is going through some of the uh training strategies popular ones not so popular ones and whatever i really find so that way we can test this using this approach to see whether they do work or they don't work and following that you can do it yourself as well so i hope you enjoyed this episode today have a great day and i will see you in the next one [Music]
Info
Channel: Dillon Grech
Views: 4,629
Rating: undefined out of 5
Keywords: dillon grech, forex trading, trading, forex, proprietary trading, prop trading, pro trader, account, the trading journal, quant trader, quant strategy, best trading strategy, quant trading, quant trading strategies, testing strategy, testing, stock market, stock trading, stock trading strategies, stock strategy, etf trading, etf strategy, donchian channel, crypto, finance, bitcoin, macd, macd strategy, macd indicator, macd trading strategy, profitable trading bot, trading bot
Id: jaOJzlVkELE
Channel Id: undefined
Length: 64min 50sec (3890 seconds)
Published: Sun Aug 15 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.