Bitcoin SCALPING strategy using Supertrend in Python — Transcript
Full transcript
- 0:00hey guys it's Sol today I want to do
- 0:01something a bit different I want to
- 0:03write a scalping strategy for the 15
- 0:05minutes time frame on the BTC chart so
- 0:09let's get right into
- 0:10it so the main indicator that I want to
- 0:13use for this strategy is called the
- 0:15super Trend and as the name indicates it
- 0:18will tell us the direction of the trend
- 0:21now when it's green we're in an uptrend
- 0:23when it's red we're in a downtrend also
- 0:25notice that when we are in an uptrend
- 0:28the value for it which is displayed here
- 0:31is actually below the current price and
- 0:33when we are in a downtrend the value for
- 0:35it is above the current price and we're
- 0:37going to use this to write our strategy
- 0:39and it's actually a pretty good
- 0:41indicator if you go back in time right
- 0:43so let's go to
- 0:45Jesse and first create a new strategy
- 0:48I'm going to call it
- 0:51scalper
- 0:52super and if I go to my
- 0:56editor and search for it
- 1:00I will find it so now this is the code
- 1:03generated by Jesse when we initiated
- 1:05this strategy from the dashboard now I
- 1:08want to use the super Trend so let's
- 1:09define a new property I want to call it
- 1:13Trend and in it I want to say that the
- 1:17variable s equals to TA super Trend I'm
- 1:23going to pass the current trends and I
- 1:25won't pass any other arguments because I
- 1:27want to use the default ones so this is
- 1:29this is it now the super Trend indicator
- 1:32in Jessie will give us two values the
- 1:34trend and the changed now the changed
- 1:37will tell us whether or not the
- 1:39direction has changed so for example if
- 1:41I zoom in here and the value that Jess
- 1:46will give us is one because the
- 1:48direction of the trend just changed but
- 1:50we don't really need that in our
- 1:51strategy so I'm not going to use that
- 1:52the only thing that I want is this value
- 1:54here which is the value that is creating
- 1:57this line here or this one so that would
- 2:01be the trend value so again I will say
- 2:04if the current price is above the trend
- 2:06value we're in uptrend so I will say if
- 2:10the current price is bigger than this
- 2:14value we're in uptrend and I want to
- 2:16return one otherwise we're in a
- 2:19downtrend so we're going to return minus
- 2:21one I will use this
- 2:23to write my shootong function so I will
- 2:26say whether or not the current Trend
- 2:28equals one and for my shoot short I will
- 2:31just do the opposite now by the way if
- 2:32you are trading the spot Market you're
- 2:34not going to use this function but
- 2:36because I'm trading Futures I will use
- 2:38it so I will say return whether or not
- 2:40the current turn equals minus one so
- 2:43this is it for my position sizing first
- 2:45I want to open the position with my
- 2:47entire capital and the entry price is
- 2:49going to be the current price in that
- 2:51moment in other words we're going to use
- 2:52a market order so I will say entry
- 2:55equals the current price and the
- 2:57quantity is going to be
- 3:00utils size to quantity for the first one
- 3:04I will pass in my entire available
- 3:06margin for this the second one I will
- 3:09pass in the entry and the Precision the
- 3:12default is fine but I will set the fee
- 3:14rate to the fee rate of the exchange
- 3:17that I'm trading on which would be self.
- 3:19Fe
- 3:20rate okay so I will say buy equals
- 3:25quantity and then entry and for my short
- 3:28function I will do the
- 3:30same and I don't need to update should
- 3:33cancel entry because again this strategy
- 3:35is using the market order to enter the
- 3:37position and what the shoot cancel entry
- 3:39order does is if you have a limit order
- 3:42or a stop order for entering your
- 3:44positions that are pending it will
- 3:46decide whether or not to cancel them so
- 3:48that you can start from scratch and do
- 3:50the calculations again but in this case
- 3:53we only have a market order for entering
- 3:55our trades so it will get executed every
- 3:57time so we don't need this so I will
- 3:59just let it be all right so now we need
- 4:02to define the exit rule for our strategy
- 4:05now what I want to do is when I get a
- 4:07trade I want to use the ATR to set my
- 4:10stoploss and the take profit now first
- 4:12let me show you the ATR on the chart now
- 4:15what this indicator does it will give me
- 4:18the average through range in other words
- 4:20it's telling me how much on average
- 4:23every new candle is changing so for
- 4:25example in this point in time the value
- 4:27for it is approximately 300
- 4:30so that means the price is on average
- 4:32changing 300 on every new candle which
- 4:34makes sense because we're trading BTC
- 4:36which has a high price so I'm going to
- 4:38use this for my stplus and I will also
- 4:41use it for my take profit so let's go
- 4:44here and I want to say when a new
- 4:47position is opened that's when I set my
- 4:49stop loss and take profit so I will
- 4:53say on open position if it's a long
- 4:57position I will say the plus is so first
- 5:01I should give it a quantity and I'm
- 5:03going to give it the entire quantity of
- 5:04my position so I will say self position.
- 5:08quantity and the second argument which
- 5:10is the price I want to say the entry
- 5:13price of my position which would be self
- 5:16position entry price we could also pass
- 5:18self. price because it's a market order
- 5:21the current price and the entry price of
- 5:23my position would be the same at this
- 5:24point but I'm going to use the position.
- 5:27Enterprise and it's going to be the
- 5:29current a R which we can get by saying
- 5:31ta. ATR and then passing current candles
- 5:35multiplied by an integer number now
- 5:38usually a number such as two or three
- 5:40works well but for this one I will use
- 5:422.5 and my take profit is going to be
- 5:46very similar except that you know it's
- 5:49going to be above the current price so
- 5:50we are adding the ATR value to our entry
- 5:53price instead of subtracting it however
- 5:55if I set the 2.5 the risk reward ratio
- 5:58of my trades will be want and
- 6:00considering that we're paying for fees
- 6:01and stuff I don't really like this
- 6:03number so I will use a bit higher number
- 6:05such as 3.2 now by the way the more you
- 6:08increase your risk to reward number yes
- 6:10you will have better trades that are
- 6:12more worth it but the win rate of your
- 6:14strategy will be lower so for example if
- 6:16I put the number two here the win rate
- 6:18of my strategy would be much higher than
- 6:21if I put something like 3.2 but on the
- 6:23other hand yes my win rate will increase
- 6:26but it doesn't mean your profits will
- 6:27increase too so I will use this this and
- 6:30I will do the opposite if it's for a
- 6:32short position so I will
- 6:34say okay the co-pilot is smart enough to
- 6:37help us here so I'm just doing the
- 6:39opposite thing for a short entry so now
- 6:42I have a complete strategy yes it's not
- 6:44improved and we're going to improve it
- 6:46in a second but I think we have a good
- 6:47enough strategy to actually execute our
- 6:50first back this so let's go back to
- 6:52Jesse and open a new back test I'm going
- 6:56to use binance peral futures for this
- 6:59back test
- 7:00but it's not my goal to exchange for
- 7:01live trading for live trading I will
- 7:03probably use either bit or Apex Pro but
- 7:05for this purpose this is fine I will
- 7:08change the time frame to 15 minutes and
- 7:10I will use the scalper super and as for
- 7:14the period I want to go back in time to
- 7:16the beginning of 2022 which was really
- 7:18bad year for crypto and I want to do it
- 7:21up until the last month and I will also
- 7:25make sure the fast mode is on and the
- 7:28Benchmark because I want want to compare
- 7:29it to the market okay this looks good
- 7:32let's run
- 7:34it okay so obviously we're not in profit
- 7:37yet however you can never make a good
- 7:39strategy with only one indicator right
- 7:41and we're only using the super Trend
- 7:43with one time frame for our in rule so
- 7:46the first thing I want to do is to make
- 7:47sure that we're only taking trades if we
- 7:49are indeed in a trending market and I
- 7:51like to use a favored indicator of mine
- 7:54called adx average directional index
- 7:57what this okay let's remove this okay so
- 8:01what this does it will give us a
- 8:03strength of the current Trend so for
- 8:06instance here where we are in a clear
- 8:08Trend the value of it rises but when we
- 8:11are in a place like here which you could
- 8:14say is a ranging Market the value of it
- 8:16drops so it's not telling us the
- 8:18direction of the trend it's just telling
- 8:19us the strength of it so the way we use
- 8:22it is usually we specify a threshold and
- 8:25say if the value of the adx is above
- 8:28this threshold we will take a trade
- 8:30otherwise we won't so let's go back to
- 8:32our strategy and I will Define the value
- 8:36for
- 8:37adx like this I will say return whether
- 8:40or not the
- 8:44adx value is bigger than 30 or
- 8:48not and now I can update my sh long and
- 8:52say
- 8:55and self. adx I will also do the same
- 8:59same for shoot
- 9:01short okay so let's go back and try
- 9:04again all right so the results clearly
- 9:08improved so that's good we are moving
- 9:10into the right direction so the first
- 9:12thing I want to do is this technique
- 9:13that I learned in a book called high
- 9:15probability trading strategies now
- 9:18basically what this book is saying that
- 9:20we can always increase our odd to our
- 9:22favor if we use a bigger time frame for
- 9:25everything so for instance if you are
- 9:27using the super Trend to determine the
- 9:29current Trend instead of only using the
- 9:31current time frame we can use a bigger
- 9:33time frame so yes we are trading with
- 9:35the 15 minutes time frame but what if we
- 9:38determine the overall trend using the 4
- 9:41hours time frame that happened to be one
- 9:42of the best techniques that I always use
- 9:44in my strategies however if you do this
- 9:47in other platforms especially on trading
- 9:49view when you're back testing there
- 9:51you're going to fall victim for the look
- 9:53ahead bias so that means you will be
- 9:55using data or the price data from the
- 9:57future that isn't realistic now I don't
- 9:59want to explain that in this video
- 10:01because it will get really long but long
- 10:03story short when you're using bigger
- 10:05time frames with Jesse you won't fall
- 10:06into that trap and if you want to know
- 10:08more about the look Ahad bias go ahead
- 10:10and look it up there are some scariest
- 10:12stories about it all right so let's go
- 10:14back to my
- 10:15strategy and before I had just one Trend
- 10:18function that was using the super Trend
- 10:21now I'm going to rename this one
- 10:24into short
- 10:27Trend and I I will copy
- 10:30this paste it here and then Define
- 10:33another one called long and I want to
- 10:36change the candles so instead of being
- 10:38the current candles I want it to be the
- 10:40candles for another time frame but
- 10:42because I might want to use those other
- 10:45candles in other parts of my code I will
- 10:47go up here and Define it
- 10:49here so I will say
- 10:52longterm
- 10:55candles would
- 10:58be get candles and the first parameter
- 11:01is the current exchange so I will pass
- 11:04the self exchange the second one is the
- 11:07symbol I will pass self symbol and for
- 11:11time frame I will pass 4 hours now you
- 11:14could pass anything you like but the
- 11:16four hours I think works pretty well
- 11:17with the 15 minutes now I can go back to
- 11:20Long Trend function and change this from
- 11:23candles into long-term candles so now I
- 11:28can update my entry to
- 11:30say and longterm equals 1 and for my
- 11:35short entry rule I can say the opposite
- 11:38so let's go back to Jesse and give it
- 11:40another try now remember this
- 11:44number and we had a huge Improvement so
- 11:48in fact we're in profit now but still
- 11:50not enough but it's in profit so this is
- 11:54really really good the Max draw down is
- 11:56also significantly lower than what we
- 11:58had before
- 11:59the win rate is at 47% okay so this is
- 12:03much better but now I want to use
- 12:05another technique that works really well
- 12:07for me and that is to define a moving
- 12:09average now imagine we could only take
- 12:12long trades if we were in a bull run now
- 12:15how do we Define that well we can do it
- 12:18with a simple
- 12:19EMA moving average
- 12:22exponential and setting the value of it
- 12:25to 200 but not only that I also want to
- 12:29use the 4 hours time frame but this one
- 12:31is with the 15 minutes so this will
- 12:34significantly make the odds in our favor
- 12:36what else it would do is to lower the
- 12:39number of Trades we're taking because
- 12:41the thing is because we're trading on
- 12:42the 15 minutes time frame we're also
- 12:44paying a lot of trading fees I mean
- 12:47imagine if we hadn't paid this much in
- 12:48fees then we would have been sitting on
- 12:50a pretty good profit right so that's
- 12:53also helpful so let's go back to our
- 12:55code and I will Define another one
- 12:59we call it
- 13:02long moving
- 13:06average and in it I will say my moving
- 13:09average equals
- 13:12ta let's use SMA here and yes I will
- 13:17pass the long-term
- 13:19candles and the period must be
- 13:23200 now if the current price is big
- 13:29bigger than the moving
- 13:32average I will return one otherwise
- 13:35return minus
- 13:37one so now I will also add this to my
- 13:39entry rules let's go to shoot
- 13:44long and say and long moving average
- 13:47equals 1 and also go to shoot short and
- 13:51say long moving average must equal minus
- 13:54one okay so now let's go back and give
- 13:57it another try
- 14:00and by the way we're getting this error
- 14:02because even though we're using the 4
- 14:03hours time frame in our strategy we
- 14:05didn't Define the data route for it in
- 14:08the dashboard and with the new version
- 14:09of Jesse if this is the case your Backes
- 14:12won't completely fail but it will warn
- 14:14you here and it's still finished okay so
- 14:17look at this the result significantly
- 14:20improved in fact considering the max
- 14:23throw down of us which is much lower
- 14:26than what the market had here you could
- 14:28say we beat Market but here's the thing
- 14:30we didn't do proper position sizing so
- 14:33so far we were opening positions with
- 14:35our entire capital and I almost never do
- 14:38that in my actual trades what I usually
- 14:40do for my position sizing is that as a
- 14:42general rule I almost never risk more
- 14:45than 2% of my capital for each trade so
- 14:48let's go to my code where I set the
- 14:50position so here I was passing the
- 14:52entire capital I want to only risk 3% so
- 14:55let's say this let's copy this and
- 14:59instead I will use another utility
- 15:02function called risk to quantity now the
- 15:05first one is the capital and again I'm
- 15:09going to pass the available
- 15:11margin and the second one is risk per
- 15:14capital and as I just said it's going to
- 15:16be 3% and the entry is going to be entry
- 15:19the other one is the suplus so that's
- 15:21very important that at the moment that
- 15:23you're opening your position and
- 15:25specifying the size of your position you
- 15:27should know what your subplus is going
- 15:28to be
- 15:30and we specify this subplus here right
- 15:35so let's copy
- 15:37this come
- 15:39here and I'm going to say S Sub equals
- 15:43this but instead of the self position.
- 15:46entry price I will say the current price
- 15:49right so here I will pass the stop and
- 15:53again the fee rate is going to be the
- 15:55current fee rate let's remove this and
- 15:59I'm going to do the same
- 16:01for short
- 16:05position all right so let's rerun the
- 16:08back
- 16:09test and see how it changes all right so
- 16:13before we w Really beating the market
- 16:16but now by the end of this period we're
- 16:19actually beating the market so that's
- 16:20how effective this change was okay so
- 16:23this looks much better and we are indeed
- 16:25beating the market but just as an
- 16:27experiment let's also to do something
- 16:29else I want to
- 16:31Define another adx but this time using
- 16:35the bigger time frame and see how that
- 16:37works so I'm going to call this one long
- 16:40adx and pass in the longterm candles and
- 16:46in my inter rule I will quickly add
- 16:55it let's rerun this
- 17:01okay it didn't help much let's also try
- 17:05using EMA instead of the SMA for the
- 17:08long-term moving
- 17:16average okay yeah this is slightly
- 17:19better the max r on decreased yeah but
- 17:21the longterm adx didn't really help so
- 17:24I'm going to remove this
- 17:31and give it one last
- 17:36try Okay this looks much
- 17:39better much better yeah especially here
- 17:42where we had a nasty downtrend we were
- 17:45up significantly so that's good but in
- 17:49here we didn't do great we also added
- 17:52not so great time here okay so let's not
- 17:55forget that this is just the initial
- 17:57version of a strategy we didn't do any
- 17:59optimization because if we do add some
- 18:02hyper parameters for example and
- 18:03optimize it using the optimization mode
- 18:05of Jesse we're going to get much better
- 18:07results and we're also still paying lots
- 18:10of trading fees here and depending on
- 18:13the plan that you have on the exchange
- 18:15or whichever exchange you're trading
- 18:17this number is also going to change a
- 18:19lot so for example if you can get some
- 18:21kind of trading fee discounts it will be
- 18:23really helpful with this strategy now I
- 18:25spent like an afternoon on this strategy
- 18:27and that obvious isn't enough for
- 18:29finding a really good one so I'm going
- 18:32to keep working on this strategy and
- 18:33trying to improve the results maybe run
- 18:35some optimization using the optimization
- 18:37mode and when I do I will submit that
- 18:40one as a premium strategy to our
- 18:42strategy listing page on our website now
- 18:45if you haven't checked out this page
- 18:46make sure to do so all right so this was
- 18:48the first strategy video that I made I
- 18:50don't know if you guys liked it or not
- 18:51so if you did and if you want me to
- 18:53continue this path and create more
- 18:55strategy videos please make sure to let
- 18:57me know in the comment section and also
- 18:59we have a giveaway a random person who
- 19:00likes this video subscribes to the
- 19:02channel and posts a comment is going to
- 19:04receive 1 million bnk token all right
- 19:07now it's time to pick the winner of the
- 19:08last
- 19:10video and the winner is I cannot
- 19:12pronounce his username but his comment
- 19:14is found you from the Apex video now I'm
- 19:17thinking if I should get life them
- 19:18subscription not to miss out on things
- 19:20for more in action I should probably get
- 19:23to know Jesse first yes that's a good
- 19:25idea thank you so much for your comment
- 19:27please reach out to me so that I can
- 19:28send you your bunk tokens all right so
- 19:31if there's a specific type of strategy
- 19:33that you want me to cover for the next
- 19:34video let me know in the comments thanks
- 19:36for watching and I'll see you in the
- 19:37next one
- 19:39[Music]
About this transcript
This page contains the full transcript of Bitcoin SCALPING strategy using Supertrend in Python by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 3,378 words across 464 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.