YouTube2Text

Bitcoin SCALPING strategy using Supertrend in Python — Transcript

by Algo-trading with Saleh · 3,378 words · 464 segments · language en · Watch on YouTube

Full transcript

  1. 0:00hey guys it's Sol today I want to do
  2. 0:01something a bit different I want to
  3. 0:03write a scalping strategy for the 15
  4. 0:05minutes time frame on the BTC chart so
  5. 0:09let's get right into
  6. 0:10it so the main indicator that I want to
  7. 0:13use for this strategy is called the
  8. 0:15super Trend and as the name indicates it
  9. 0:18will tell us the direction of the trend
  10. 0:21now when it's green we're in an uptrend
  11. 0:23when it's red we're in a downtrend also
  12. 0:25notice that when we are in an uptrend
  13. 0:28the value for it which is displayed here
  14. 0:31is actually below the current price and
  15. 0:33when we are in a downtrend the value for
  16. 0:35it is above the current price and we're
  17. 0:37going to use this to write our strategy
  18. 0:39and it's actually a pretty good
  19. 0:41indicator if you go back in time right
  20. 0:43so let's go to
  21. 0:45Jesse and first create a new strategy
  22. 0:48I'm going to call it
  23. 0:51scalper
  24. 0:52super and if I go to my
  25. 0:56editor and search for it
  26. 1:00I will find it so now this is the code
  27. 1:03generated by Jesse when we initiated
  28. 1:05this strategy from the dashboard now I
  29. 1:08want to use the super Trend so let's
  30. 1:09define a new property I want to call it
  31. 1:13Trend and in it I want to say that the
  32. 1:17variable s equals to TA super Trend I'm
  33. 1:23going to pass the current trends and I
  34. 1:25won't pass any other arguments because I
  35. 1:27want to use the default ones so this is
  36. 1:29this is it now the super Trend indicator
  37. 1:32in Jessie will give us two values the
  38. 1:34trend and the changed now the changed
  39. 1:37will tell us whether or not the
  40. 1:39direction has changed so for example if
  41. 1:41I zoom in here and the value that Jess
  42. 1:46will give us is one because the
  43. 1:48direction of the trend just changed but
  44. 1:50we don't really need that in our
  45. 1:51strategy so I'm not going to use that
  46. 1:52the only thing that I want is this value
  47. 1:54here which is the value that is creating
  48. 1:57this line here or this one so that would
  49. 2:01be the trend value so again I will say
  50. 2:04if the current price is above the trend
  51. 2:06value we're in uptrend so I will say if
  52. 2:10the current price is bigger than this
  53. 2:14value we're in uptrend and I want to
  54. 2:16return one otherwise we're in a
  55. 2:19downtrend so we're going to return minus
  56. 2:21one I will use this
  57. 2:23to write my shootong function so I will
  58. 2:26say whether or not the current Trend
  59. 2:28equals one and for my shoot short I will
  60. 2:31just do the opposite now by the way if
  61. 2:32you are trading the spot Market you're
  62. 2:34not going to use this function but
  63. 2:36because I'm trading Futures I will use
  64. 2:38it so I will say return whether or not
  65. 2:40the current turn equals minus one so
  66. 2:43this is it for my position sizing first
  67. 2:45I want to open the position with my
  68. 2:47entire capital and the entry price is
  69. 2:49going to be the current price in that
  70. 2:51moment in other words we're going to use
  71. 2:52a market order so I will say entry
  72. 2:55equals the current price and the
  73. 2:57quantity is going to be
  74. 3:00utils size to quantity for the first one
  75. 3:04I will pass in my entire available
  76. 3:06margin for this the second one I will
  77. 3:09pass in the entry and the Precision the
  78. 3:12default is fine but I will set the fee
  79. 3:14rate to the fee rate of the exchange
  80. 3:17that I'm trading on which would be self.
  81. 3:19Fe
  82. 3:20rate okay so I will say buy equals
  83. 3:25quantity and then entry and for my short
  84. 3:28function I will do the
  85. 3:30same and I don't need to update should
  86. 3:33cancel entry because again this strategy
  87. 3:35is using the market order to enter the
  88. 3:37position and what the shoot cancel entry
  89. 3:39order does is if you have a limit order
  90. 3:42or a stop order for entering your
  91. 3:44positions that are pending it will
  92. 3:46decide whether or not to cancel them so
  93. 3:48that you can start from scratch and do
  94. 3:50the calculations again but in this case
  95. 3:53we only have a market order for entering
  96. 3:55our trades so it will get executed every
  97. 3:57time so we don't need this so I will
  98. 3:59just let it be all right so now we need
  99. 4:02to define the exit rule for our strategy
  100. 4:05now what I want to do is when I get a
  101. 4:07trade I want to use the ATR to set my
  102. 4:10stoploss and the take profit now first
  103. 4:12let me show you the ATR on the chart now
  104. 4:15what this indicator does it will give me
  105. 4:18the average through range in other words
  106. 4:20it's telling me how much on average
  107. 4:23every new candle is changing so for
  108. 4:25example in this point in time the value
  109. 4:27for it is approximately 300
  110. 4:30so that means the price is on average
  111. 4:32changing 300 on every new candle which
  112. 4:34makes sense because we're trading BTC
  113. 4:36which has a high price so I'm going to
  114. 4:38use this for my stplus and I will also
  115. 4:41use it for my take profit so let's go
  116. 4:44here and I want to say when a new
  117. 4:47position is opened that's when I set my
  118. 4:49stop loss and take profit so I will
  119. 4:53say on open position if it's a long
  120. 4:57position I will say the plus is so first
  121. 5:01I should give it a quantity and I'm
  122. 5:03going to give it the entire quantity of
  123. 5:04my position so I will say self position.
  124. 5:08quantity and the second argument which
  125. 5:10is the price I want to say the entry
  126. 5:13price of my position which would be self
  127. 5:16position entry price we could also pass
  128. 5:18self. price because it's a market order
  129. 5:21the current price and the entry price of
  130. 5:23my position would be the same at this
  131. 5:24point but I'm going to use the position.
  132. 5:27Enterprise and it's going to be the
  133. 5:29current a R which we can get by saying
  134. 5:31ta. ATR and then passing current candles
  135. 5:35multiplied by an integer number now
  136. 5:38usually a number such as two or three
  137. 5:40works well but for this one I will use
  138. 5:422.5 and my take profit is going to be
  139. 5:46very similar except that you know it's
  140. 5:49going to be above the current price so
  141. 5:50we are adding the ATR value to our entry
  142. 5:53price instead of subtracting it however
  143. 5:55if I set the 2.5 the risk reward ratio
  144. 5:58of my trades will be want and
  145. 6:00considering that we're paying for fees
  146. 6:01and stuff I don't really like this
  147. 6:03number so I will use a bit higher number
  148. 6:05such as 3.2 now by the way the more you
  149. 6:08increase your risk to reward number yes
  150. 6:10you will have better trades that are
  151. 6:12more worth it but the win rate of your
  152. 6:14strategy will be lower so for example if
  153. 6:16I put the number two here the win rate
  154. 6:18of my strategy would be much higher than
  155. 6:21if I put something like 3.2 but on the
  156. 6:23other hand yes my win rate will increase
  157. 6:26but it doesn't mean your profits will
  158. 6:27increase too so I will use this this and
  159. 6:30I will do the opposite if it's for a
  160. 6:32short position so I will
  161. 6:34say okay the co-pilot is smart enough to
  162. 6:37help us here so I'm just doing the
  163. 6:39opposite thing for a short entry so now
  164. 6:42I have a complete strategy yes it's not
  165. 6:44improved and we're going to improve it
  166. 6:46in a second but I think we have a good
  167. 6:47enough strategy to actually execute our
  168. 6:50first back this so let's go back to
  169. 6:52Jesse and open a new back test I'm going
  170. 6:56to use binance peral futures for this
  171. 6:59back test
  172. 7:00but it's not my goal to exchange for
  173. 7:01live trading for live trading I will
  174. 7:03probably use either bit or Apex Pro but
  175. 7:05for this purpose this is fine I will
  176. 7:08change the time frame to 15 minutes and
  177. 7:10I will use the scalper super and as for
  178. 7:14the period I want to go back in time to
  179. 7:16the beginning of 2022 which was really
  180. 7:18bad year for crypto and I want to do it
  181. 7:21up until the last month and I will also
  182. 7:25make sure the fast mode is on and the
  183. 7:28Benchmark because I want want to compare
  184. 7:29it to the market okay this looks good
  185. 7:32let's run
  186. 7:34it okay so obviously we're not in profit
  187. 7:37yet however you can never make a good
  188. 7:39strategy with only one indicator right
  189. 7:41and we're only using the super Trend
  190. 7:43with one time frame for our in rule so
  191. 7:46the first thing I want to do is to make
  192. 7:47sure that we're only taking trades if we
  193. 7:49are indeed in a trending market and I
  194. 7:51like to use a favored indicator of mine
  195. 7:54called adx average directional index
  196. 7:57what this okay let's remove this okay so
  197. 8:01what this does it will give us a
  198. 8:03strength of the current Trend so for
  199. 8:06instance here where we are in a clear
  200. 8:08Trend the value of it rises but when we
  201. 8:11are in a place like here which you could
  202. 8:14say is a ranging Market the value of it
  203. 8:16drops so it's not telling us the
  204. 8:18direction of the trend it's just telling
  205. 8:19us the strength of it so the way we use
  206. 8:22it is usually we specify a threshold and
  207. 8:25say if the value of the adx is above
  208. 8:28this threshold we will take a trade
  209. 8:30otherwise we won't so let's go back to
  210. 8:32our strategy and I will Define the value
  211. 8:36for
  212. 8:37adx like this I will say return whether
  213. 8:40or not the
  214. 8:44adx value is bigger than 30 or
  215. 8:48not and now I can update my sh long and
  216. 8:52say
  217. 8:55and self. adx I will also do the same
  218. 8:59same for shoot
  219. 9:01short okay so let's go back and try
  220. 9:04again all right so the results clearly
  221. 9:08improved so that's good we are moving
  222. 9:10into the right direction so the first
  223. 9:12thing I want to do is this technique
  224. 9:13that I learned in a book called high
  225. 9:15probability trading strategies now
  226. 9:18basically what this book is saying that
  227. 9:20we can always increase our odd to our
  228. 9:22favor if we use a bigger time frame for
  229. 9:25everything so for instance if you are
  230. 9:27using the super Trend to determine the
  231. 9:29current Trend instead of only using the
  232. 9:31current time frame we can use a bigger
  233. 9:33time frame so yes we are trading with
  234. 9:35the 15 minutes time frame but what if we
  235. 9:38determine the overall trend using the 4
  236. 9:41hours time frame that happened to be one
  237. 9:42of the best techniques that I always use
  238. 9:44in my strategies however if you do this
  239. 9:47in other platforms especially on trading
  240. 9:49view when you're back testing there
  241. 9:51you're going to fall victim for the look
  242. 9:53ahead bias so that means you will be
  243. 9:55using data or the price data from the
  244. 9:57future that isn't realistic now I don't
  245. 9:59want to explain that in this video
  246. 10:01because it will get really long but long
  247. 10:03story short when you're using bigger
  248. 10:05time frames with Jesse you won't fall
  249. 10:06into that trap and if you want to know
  250. 10:08more about the look Ahad bias go ahead
  251. 10:10and look it up there are some scariest
  252. 10:12stories about it all right so let's go
  253. 10:14back to my
  254. 10:15strategy and before I had just one Trend
  255. 10:18function that was using the super Trend
  256. 10:21now I'm going to rename this one
  257. 10:24into short
  258. 10:27Trend and I I will copy
  259. 10:30this paste it here and then Define
  260. 10:33another one called long and I want to
  261. 10:36change the candles so instead of being
  262. 10:38the current candles I want it to be the
  263. 10:40candles for another time frame but
  264. 10:42because I might want to use those other
  265. 10:45candles in other parts of my code I will
  266. 10:47go up here and Define it
  267. 10:49here so I will say
  268. 10:52longterm
  269. 10:55candles would
  270. 10:58be get candles and the first parameter
  271. 11:01is the current exchange so I will pass
  272. 11:04the self exchange the second one is the
  273. 11:07symbol I will pass self symbol and for
  274. 11:11time frame I will pass 4 hours now you
  275. 11:14could pass anything you like but the
  276. 11:16four hours I think works pretty well
  277. 11:17with the 15 minutes now I can go back to
  278. 11:20Long Trend function and change this from
  279. 11:23candles into long-term candles so now I
  280. 11:28can update my entry to
  281. 11:30say and longterm equals 1 and for my
  282. 11:35short entry rule I can say the opposite
  283. 11:38so let's go back to Jesse and give it
  284. 11:40another try now remember this
  285. 11:44number and we had a huge Improvement so
  286. 11:48in fact we're in profit now but still
  287. 11:50not enough but it's in profit so this is
  288. 11:54really really good the Max draw down is
  289. 11:56also significantly lower than what we
  290. 11:58had before
  291. 11:59the win rate is at 47% okay so this is
  292. 12:03much better but now I want to use
  293. 12:05another technique that works really well
  294. 12:07for me and that is to define a moving
  295. 12:09average now imagine we could only take
  296. 12:12long trades if we were in a bull run now
  297. 12:15how do we Define that well we can do it
  298. 12:18with a simple
  299. 12:19EMA moving average
  300. 12:22exponential and setting the value of it
  301. 12:25to 200 but not only that I also want to
  302. 12:29use the 4 hours time frame but this one
  303. 12:31is with the 15 minutes so this will
  304. 12:34significantly make the odds in our favor
  305. 12:36what else it would do is to lower the
  306. 12:39number of Trades we're taking because
  307. 12:41the thing is because we're trading on
  308. 12:42the 15 minutes time frame we're also
  309. 12:44paying a lot of trading fees I mean
  310. 12:47imagine if we hadn't paid this much in
  311. 12:48fees then we would have been sitting on
  312. 12:50a pretty good profit right so that's
  313. 12:53also helpful so let's go back to our
  314. 12:55code and I will Define another one
  315. 12:59we call it
  316. 13:02long moving
  317. 13:06average and in it I will say my moving
  318. 13:09average equals
  319. 13:12ta let's use SMA here and yes I will
  320. 13:17pass the long-term
  321. 13:19candles and the period must be
  322. 13:23200 now if the current price is big
  323. 13:29bigger than the moving
  324. 13:32average I will return one otherwise
  325. 13:35return minus
  326. 13:37one so now I will also add this to my
  327. 13:39entry rules let's go to shoot
  328. 13:44long and say and long moving average
  329. 13:47equals 1 and also go to shoot short and
  330. 13:51say long moving average must equal minus
  331. 13:54one okay so now let's go back and give
  332. 13:57it another try
  333. 14:00and by the way we're getting this error
  334. 14:02because even though we're using the 4
  335. 14:03hours time frame in our strategy we
  336. 14:05didn't Define the data route for it in
  337. 14:08the dashboard and with the new version
  338. 14:09of Jesse if this is the case your Backes
  339. 14:12won't completely fail but it will warn
  340. 14:14you here and it's still finished okay so
  341. 14:17look at this the result significantly
  342. 14:20improved in fact considering the max
  343. 14:23throw down of us which is much lower
  344. 14:26than what the market had here you could
  345. 14:28say we beat Market but here's the thing
  346. 14:30we didn't do proper position sizing so
  347. 14:33so far we were opening positions with
  348. 14:35our entire capital and I almost never do
  349. 14:38that in my actual trades what I usually
  350. 14:40do for my position sizing is that as a
  351. 14:42general rule I almost never risk more
  352. 14:45than 2% of my capital for each trade so
  353. 14:48let's go to my code where I set the
  354. 14:50position so here I was passing the
  355. 14:52entire capital I want to only risk 3% so
  356. 14:55let's say this let's copy this and
  357. 14:59instead I will use another utility
  358. 15:02function called risk to quantity now the
  359. 15:05first one is the capital and again I'm
  360. 15:09going to pass the available
  361. 15:11margin and the second one is risk per
  362. 15:14capital and as I just said it's going to
  363. 15:16be 3% and the entry is going to be entry
  364. 15:19the other one is the suplus so that's
  365. 15:21very important that at the moment that
  366. 15:23you're opening your position and
  367. 15:25specifying the size of your position you
  368. 15:27should know what your subplus is going
  369. 15:28to be
  370. 15:30and we specify this subplus here right
  371. 15:35so let's copy
  372. 15:37this come
  373. 15:39here and I'm going to say S Sub equals
  374. 15:43this but instead of the self position.
  375. 15:46entry price I will say the current price
  376. 15:49right so here I will pass the stop and
  377. 15:53again the fee rate is going to be the
  378. 15:55current fee rate let's remove this and
  379. 15:59I'm going to do the same
  380. 16:01for short
  381. 16:05position all right so let's rerun the
  382. 16:08back
  383. 16:09test and see how it changes all right so
  384. 16:13before we w Really beating the market
  385. 16:16but now by the end of this period we're
  386. 16:19actually beating the market so that's
  387. 16:20how effective this change was okay so
  388. 16:23this looks much better and we are indeed
  389. 16:25beating the market but just as an
  390. 16:27experiment let's also to do something
  391. 16:29else I want to
  392. 16:31Define another adx but this time using
  393. 16:35the bigger time frame and see how that
  394. 16:37works so I'm going to call this one long
  395. 16:40adx and pass in the longterm candles and
  396. 16:46in my inter rule I will quickly add
  397. 16:55it let's rerun this
  398. 17:01okay it didn't help much let's also try
  399. 17:05using EMA instead of the SMA for the
  400. 17:08long-term moving
  401. 17:16average okay yeah this is slightly
  402. 17:19better the max r on decreased yeah but
  403. 17:21the longterm adx didn't really help so
  404. 17:24I'm going to remove this
  405. 17:31and give it one last
  406. 17:36try Okay this looks much
  407. 17:39better much better yeah especially here
  408. 17:42where we had a nasty downtrend we were
  409. 17:45up significantly so that's good but in
  410. 17:49here we didn't do great we also added
  411. 17:52not so great time here okay so let's not
  412. 17:55forget that this is just the initial
  413. 17:57version of a strategy we didn't do any
  414. 17:59optimization because if we do add some
  415. 18:02hyper parameters for example and
  416. 18:03optimize it using the optimization mode
  417. 18:05of Jesse we're going to get much better
  418. 18:07results and we're also still paying lots
  419. 18:10of trading fees here and depending on
  420. 18:13the plan that you have on the exchange
  421. 18:15or whichever exchange you're trading
  422. 18:17this number is also going to change a
  423. 18:19lot so for example if you can get some
  424. 18:21kind of trading fee discounts it will be
  425. 18:23really helpful with this strategy now I
  426. 18:25spent like an afternoon on this strategy
  427. 18:27and that obvious isn't enough for
  428. 18:29finding a really good one so I'm going
  429. 18:32to keep working on this strategy and
  430. 18:33trying to improve the results maybe run
  431. 18:35some optimization using the optimization
  432. 18:37mode and when I do I will submit that
  433. 18:40one as a premium strategy to our
  434. 18:42strategy listing page on our website now
  435. 18:45if you haven't checked out this page
  436. 18:46make sure to do so all right so this was
  437. 18:48the first strategy video that I made I
  438. 18:50don't know if you guys liked it or not
  439. 18:51so if you did and if you want me to
  440. 18:53continue this path and create more
  441. 18:55strategy videos please make sure to let
  442. 18:57me know in the comment section and also
  443. 18:59we have a giveaway a random person who
  444. 19:00likes this video subscribes to the
  445. 19:02channel and posts a comment is going to
  446. 19:04receive 1 million bnk token all right
  447. 19:07now it's time to pick the winner of the
  448. 19:08last
  449. 19:10video and the winner is I cannot
  450. 19:12pronounce his username but his comment
  451. 19:14is found you from the Apex video now I'm
  452. 19:17thinking if I should get life them
  453. 19:18subscription not to miss out on things
  454. 19:20for more in action I should probably get
  455. 19:23to know Jesse first yes that's a good
  456. 19:25idea thank you so much for your comment
  457. 19:27please reach out to me so that I can
  458. 19:28send you your bunk tokens all right so
  459. 19:31if there's a specific type of strategy
  460. 19:33that you want me to cover for the next
  461. 19:34video let me know in the comments thanks
  462. 19:36for watching and I'll see you in the
  463. 19:37next one
  464. 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.