YouTube Video
YouTube Video Transcript
[Music] hey this is David for big bits in this video our tenth video in the pine script development tutorial series we are going to talk about percentage based profits and stop losses so these are actually going to be market orders with the strategy and if you’ve been following along you’ll notice I’ve cleaned up the strategy quite a bit it’s very basic if you’ve just joined in this video it’s gonna look kind of dumb because the strategy is just worthless when you’re looking at it but that’s because we’ve made it highly flexible and this is just an example for the tutorial series now you can see the strategy has it by when we have the crossover of our first moving average over the second one and we’ve added in the new feature of the take profit or stop-loss which had it exit here with a stop loss of 15% now I get into how that works again in just a minute but we also had a buy here and it continued to sell with our old strategy settings of crossing under the second moving average as well so we’ve managed to add in our take profit and stop-loss alongside of our moving average crossovers that we use to also potentially exit the trades now if all this sounds confusing in your head and watch the previous videos it’s probably a good idea to go back and maybe even start from the beginning so let’s continue on and let’s take a look at how this is actually done now the only difference we’ve made in our actual strategy entries or exits is we’ve added a new line in every condition where we had an entry we placed an exit and what the exit does it essentially triggers a market order once your profit gets hit or your loss gets hit now these are all different parameters in the exit function and let’s take a look the first one is profit or lot the profit or loss excuse me and that’s the text you’re gonna see here on the strategy itself when it prints on the chart and we’ve associated that with the one over to entry ID and we have created a new called profit target and a new variable called lost target these are used to calculate the percentage differences so that we can actually get the right numbers for it to exit at no matter what we are looking at now I’ll go over how we calculate those in just a minute but let’s go over how the profit and loss targets actually work when you’re working with the exit now keep in mind we are just doing market orders there is an option to use a limit order to take profit it’s not a big deal to me to use the market orders personally I don’t trade very often with strategies might look at a daily chart and trade on strategies so there’s probably not gonna be a lot of trades going on for me so the market fees aren’t that big of a deal but if you’re interested in using limit orders to trade shorter timeframes – and in most cases you get better fee rates on limit orders so you might want to consider using limit for your take profit instead of a market order but we’re going to use market and when we do this we have to give the parameter a value that it expects and that value is based in ticks now what a tick is that is the interval between prices shown on the chart and let’s go back to our chart here you can see the interval on our chart here is based in pennies since we’re using the US dollar as our base currency here so each tick is point zero one dollars or one cent now if we wanted to set our take profit exactly one dollar above where our entry was we would have to use 100 ticks so to do this with percentages we have to calculate it and the same thing goes for the loss parameter it’s also calculated in ticks now it’s important to note that the loss isn’t really a negative number that you’re working with the the system knows that the loss is a negative number the measurement in ticks is just that it’s a measurement so it’s gonna be a positive number so if you’re going down you don’t have to use a negative tick number it’s just a measure of distance downward and the system knows that and I’ll show you how we calculate that in just a moment but before we do the catch that’s right here I’ll explain that all much better in just a moment but let’s take a look we had to add some new inputs here we added our take profit percentage and our stop loss percentage we have the minimum value at point zero one and once again that’s because they have to be positive numbers even though you’re setting a loss below where you enter and I set the step size which is the interval between the values on the settings to point five we’ll just half a percent if you need to tune that down you can just change it to 0.25 or 0.1 whatever you want but let me show you the settings here and show you how this is gonna actually impact the chart now I have some arbitrary numbers of 30 and 15 percent said it’s the profit and loss respectively and this probably won’t work for most people it probably wouldn’t even work for me but for our example purpose here I’m going to change the stop-loss percentage to 15.5% and you should see that this actually moves down to the next candle because the percentage down increased now you can see I just kind of proved my point that the percentage increases on the stop-loss means it goes down further and you don’t have to use a negative percentage on tradingview like that so I’m just gonna save our changes to our settings there I’m gonna go back down let’s look at our calculations for how we calculated how many ticks we would need now the profit target this is a pretty straightforward calculation we have our clothes times our percentage divided by how many ticks we have now let me explain this and I can actually kind of show you through some of the math here our take profit percentage is 30% now we have to divide that by 100 so we get the actual value we need to multiply the close by so if it’s 30% and we have the number 30 we have divided by 100 we now have 0.3 okay if the price were say $10,000 and that was the close we would multiply that by 0.3 which is $3,000 now if we were to just use 3000 ticks and I remember the ticks are point zero one on this chart so if we did 3000 of those that would only be 30 dollars up for our take profit and that’s not what we want we want 30% based on the example which would be 3000 so we divide that 3000 by the minimum tick size by that point zero one and now it’s I believe 300,000 so now it’ll actually place the product the the take profit up three thousand dollars at 13,000 and similarly we do the same exact calculation for the Lost Target we just use the stop-loss percentage instead in that calculation so there you have it that’s really all there is to it I’m trying to think if there’s really anything else to do here with the staff lock the stop loss and take profit I really don’t think there is in this video you can see where we entered and where we exit if you have an idea of something you like to see added to this please leave a comment if you liked the video definitely please like it if you like videos like this please subscribe I’m always coming out with new ones related to development Trading cryptocurrency those sorts of things so I would really appreciate that if you would but stay tuned to the next video and you know have a great day [Music]
YouTube Video Description
< br/> ???? IMPORTANT LINKS BELOW ????
TradingView Take Profit & Stop Loss: In this TradingView Pine Script Tutorial we discuss how to apply a customizable Take Profit and Stop Loss onto our strategy. With these customizable settings, you can adjust your percentage Take Profit and Stop Loss on the fly to quickly re-evaluate your strategy with these new values. 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: https://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!