TradingView Pine Script Tutorial 33 – Setting Strategy to Enter Shorts

TradingView Pine Script Tutorial 33 – Setting Strategy to Enter Shorts

YouTube Video

YouTube Video Transcript

hey this is David for big bits and in this video we are going to discuss shorting finally with our strategies that we’ve been working with in this series we are gonna borrow some code from earlier on in the tutorial series that we use to actually first get acquainted with entering positions and exiting positions using the strategy feature with pine on trading view now the script that we used before is available on my profile and I already mentioned it’s available in the videos as a part of this tutorial series so if you haven’t subscribed already please subscribe and you’ll get to see when more videos are coming out related to this kind of stuff but if you go to my profile on trading view which there’s a link for in the description down there below the video hit scripts here on my profile and that’ll take you to the list of all my scripts and the one that I’m gonna be working on which I’ve already found for us is the very last one we did in the main part of the tutorial series which covered commissions and fees mainly just because this is the last one we did as a part of the mainland we’re not focusing on Commission and fees right now what we are going to be doing is similar to this is we bought or we went long when we had crossovers from a shorter time frame moving average over a longer time frame now this we’re not we’re not gonna use three different moving averages what we’re actually going to be doing is just using two and we’re actually going to short when one goes under the other seeing so here the green one went under the yellow in this particular example we’re gonna do short at that point now I’m going to show you the script in just a moment and talk about it but there are a couple of things we’re gonna borrow because this is essentially the same thing as going long as we did in the previous video as far as the code is concerned except we’re only telling it that we’re going to be going short now instead of going long otherwise it’s pretty much the same concept now we are going to be using our moving average inputs we’re gonna be using our take profit and stop-loss just because those are always a good idea in my opinion to have on my scripts they help me get a better idea of when things would actually occur and we are also going to be doing where is it of course we’re going to calculate those take profit and stop-loss targets but we’re also going to be using code very similar to this where we are checking for our conditions to be true so that we can enter close and also provide our profit and loss targets so that we can exit based on our entry as well so let’s go ahead and take a look at the actual code we’re going to be working with today and you can see here this is what we’re going to be working with as far as what’s being plotted on the screen and the red label here is when we would have shorted and the purple is when we would have exited the position and there’s only gonna be one position here so we entered and exited here entered exited here entered exited so you kind of get the picture this actually seems to have done pretty well here over the last couple of months for Bitcoin on this particular chart but this is just a coincidence there’s really no rhyme or reason to this example that I’m doing other than it is a Golden Cross so we are using an input period of 50 and 200 for our moving averages those are going to be smooth and moving averages and we’re going to store those in a variables MA 1 and ma 2 we are going to have a take profit and a stop loss at 10% so since we’re doing a short our take profit is no longer above our entry point since we are trying to take profit below with a short then our take profit is down here so when the profit or loss gets triggered this is part of either our take profit or our stop loss and we know that because this is a short we are actually taking profit because the profit loss exit gets called below the entry parts of the short now whereas if the profit or loss occurred above the entry price then that would indicate that was actually a stop loss that got hit now we have already borrowed a lot of this code from the previous script that we’ve already done we’ve calculated our moving averages we’ve plotted our moving averages and just to be clear the lime color line the Green Line is the 50 period moving average in the red line is the 200 period moving average so what are our conditions to sell and we’re also using our sale condition to short as well and all we’re requiring is that the moving average of one crosses under moving average – so when the MA one the Green Line goes under MA – we’re going to tell it that we should sell now conversely we have a condition called is a buy and we’re going to quote buy when the Green Line crosses over the red line now we’re only actually going to buy in the sense that we would have to buy back to close our position in this case so all we’re really doing when we say is a buy with a short is we’re actually just closing the position now it can’t get a little bit more complicated if you’re working with multiple orders or worrying about multiple positions with a single strategy but we’re working with all of our equity or all of our capital that we’re gonna be using to trade within one trade so this doesn’t really scale too well if you’re trying to keep track of some other sorts of things but for the example just showing you how short works this is gonna work pretty well and now that we know our conditions whether this is currently a cell or this currently is a by so we could close our short then we can make our decisions so if this is a cell we can enter our short and that’s what we do here the main difference will really the only difference is that I’ve changed the title here and we’ve told it to use false here and the reason that is because on the strategy entry and you can see when I hover over here but I’m going to click on the reference manual pop up here so we can see this a little bit better is that these the parameters that it uses and you’ll notice the second parameter is one called long now with long that’s actually a boolean value and that just means that if you have this set to true that you’re telling that the script that this position should be a law whereas if you put in false like we did here that’ll tell the script that your entry for this strategy on this particular line should be a short now all the other code is the same with our exit we set our profit and our stop loss that we had calculated earlier and then of course our other way to exit our strategy was if the by condition or the short closed condition was triggered as well and then we could close the strategy based on its ID there so that pretty much covers basics of doing shorting I’d like to do a video soon where we could cover going long and short pretty much just alternating positions or switching back and forth between positions to really maximize your time exposed to a position and increase your chances hopefully of creating more profit now that’s yet to be seen how that’s actually gonna work we’re probably just gonna use the same example with our moving averages here with the 50 and the 200 since this works well with golden and death crosses and we’ll just see what we can do to make this work with going long and then also shorting some as well now also I have some other video ideas coming up for trading view and pine script in general there’s a lot of requests out there I want to get to working with plotting some lines and well there are some other plots that people would like to see people would like to see some supports and resistance mapped out I’d also like to look at pivots there’s a lot of things that we haven’t even covered yet and we’re 32 or 33 videos in at this point right now maybe more if you include the introduction video in that count so we’re quite a ways in and we’re still still just kind of scratching the surface on what you can actually do in pine and there’s a lot of very good scripts out there if you check trading views public profile there’s a lot of really in-depth technical and complicated scripts where people have done a lot of work and the things that we’ve covered so far don’t really give just as to what you can actually do with time so definitely subscribe to the channel we’re going to go further and further down this path and we’re gonna be working with more and more complicated code I want to cover all the basics and discuss some of the main ideas before we really venture off into our own indicators and our own strategies and the channel when we have more time for that so that’s it for this video as always please subscribe and while you’re down there please like the video you can always also check out the tradingview profile and other social media where you can follow me on there to get updates on scripts and things like that and then if you’ve been following and you’ve created a trading account or you’re thinking of creating a trading account with a paid plan please consider using the referral link in the description of the video because you will also get $30 towards your upgraded plan when you use the referral link and so will I and that’ll help you and it’ll help me as well and I would appreciate it very much so that’s it for today and look forward to some new videos coming out soon thank you and have a nice day [Music]

YouTube Video Description

< br/> ๐Ÿ”ป๐Ÿ”ป๐Ÿ”ป๐Ÿ”ป IMPORTANT LINKS BELOW ๐Ÿ”ป๐Ÿ”ป๐Ÿ”ป๐Ÿ”ป
๐Ÿ“ˆ Sign up for a paid plan at TradingView and receive a $30 credit: https://www.tradingview.com/gopro/?share_your_love=BigBitsIO

๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ
Social and other public profiles
๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ
๐Ÿ’ป Website: https://www.bigbits.io
๐ŸŽฎ Discord: https://discord.gg/rapMn4z
๐Ÿฆ Twitter: https://twitter.com/BigBitsIO
๐Ÿ“” Facebook: https://www.facebook.com/BigBitsIO/
๐Ÿ‘จโ€๐Ÿ’ปGitHub: https://github.com/BigBitsIO
๐Ÿ“ˆTradingView: https://www.tradingview.com/u/BigBitsIO

๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ
Referral links
๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ๐Ÿ’ฐ
๐Ÿ“ˆ Buy, Sell and Trade Crypto on Binance.US with LOW fees: https://www.binance.us/?ref=35105151
๐Ÿ™‹โ€โ™‚๏ธ Want to buy crypto? Get $10 of bitcoin w/ your first purchase over $100: https://www.coinbase.com/join/johnso_dxz
๐Ÿ“ˆ Sign up for a paid plan at TradingView and receive a $30 credit: https://www.tradingview.com/gopro/?share_your_love=BigBitsIO
๐Ÿ’ป Browse privately and get rewarded with Brave Browser: https://brave.com/big406
๐Ÿ•น Receive bonus perks when purchasing Lightnite Game: https://lightnite.io/ref=BigBits
VIEW ALL HERE: https://bigbits.io/bigbits-referrals/

โ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธโ—๏ธ
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!