YouTube2Text

1. Routes - Algo trading from scratch with Python — Transcript

by Algo-trading with Saleh · 1,709 words · 261 segments · language en · Watch on YouTube

Full transcript

  1. 0:02in this video i will explain what
  2. 0:04justice routes are and then i'll show
  3. 0:05you different examples of how to use
  4. 0:07them
  5. 0:12a route is used to tell jesse where to
  6. 0:14trade what to trade in which time frame
  7. 0:17and using which strategy i'll show you a
  8. 0:19basic example in a second and then i'll
  9. 0:22show you how to go further by using
  10. 0:23multiple symbols and time frames inside
  11. 0:25the same strategy let's get started i
  12. 0:28will dive into strategy development in
  13. 0:30one of the upcoming videos but in this
  14. 0:32one i still need a simple strategy to
  15. 0:34show you how to use routes so i'm gonna
  16. 0:36start by writing a golden cross strategy
  17. 0:38which is like the hello world of algo
  18. 0:40trading i don't want to do short selling
  19. 0:43here so i'll just remove the shoot short
  20. 0:45and go short methods i'll begin by
  21. 0:47defining two moving averages whenever
  22. 0:49the one with the shorter period crosses
  23. 0:51the longer one we open a long position
  24. 0:54the period for the short ema is going to
  25. 0:56be 21 and for the longer one
  26. 1:00i'll use
  27. 1:0150
  28. 1:02and to define the cross i'll say return
  29. 1:05true whenever the short ema is bigger
  30. 1:08than
  31. 1:09the long ema
  32. 1:10since i'll be using a market order for
  33. 1:13entering my trades the value of should
  34. 1:16cancel entry doesn't really matter but
  35. 1:17i'll return true just because it's good
  36. 1:19practice
  37. 1:20as for my entry order i want to use all
  38. 1:23the existing balance in my account and
  39. 1:26for the entry price i want to use the
  40. 1:28current price in other words i want to
  41. 1:30use a market order so i'll say quantity
  42. 1:33equals
  43. 1:35utils dot size to quantity
  44. 1:39first parameter is going to be my
  45. 1:41current balance
  46. 1:43the second one will be the entry price
  47. 1:45actually let's define the entry price as
  48. 1:47a separate variable and use it here
  49. 1:51now i can define the buy order by saying
  50. 1:54self dot by equals
  51. 1:57quantity
  52. 1:58comma
  53. 2:00enter price
  54. 2:01as for exiting my positions i want to do
  55. 2:03it whenever the opposite of my intrude
  56. 2:05rule happens
  57. 2:07first i'll define the object position
  58. 2:09method
  59. 2:11then i will copy the code for my moving
  60. 2:14averages paste it here
  61. 2:16and
  62. 2:17i'll say if the short ema is smaller
  63. 2:20than the long ema liquidate my position
  64. 2:23all right now i have a basic strategy
  65. 2:26let's say i want to backtest this
  66. 2:28strategy on binance spot
  67. 2:31and the symbol of btc usdt
  68. 2:34using the 15 minutes time frame
  69. 2:37and the strategy is is going to be the
  70. 2:39example of strategy which is what we
  71. 2:40just defined now let's head to the back
  72. 2:42testing page and see how we can define
  73. 2:45the route for it inside the route
  74. 2:47section you will always find at least
  75. 2:49one existing route that's because it is
  76. 2:51the minimum requirement so i can just
  77. 2:53modify the existing one for the exchange
  78. 2:55i will choose binance spot
  79. 2:58the symbol is already btc uct but even
  80. 3:01if it wasn't i could enter it here
  81. 3:04and the time frame will be 15 minutes
  82. 3:07and the strategy is already selected
  83. 3:10because there's only one strategy in my
  84. 3:12current directory and that's a basic
  85. 3:14route now i could just sort the back
  86. 3:16test by selecting the duration first
  87. 3:19and pressing the start button
  88. 3:26you can also trade multiple symbols at
  89. 3:29the same time whether with the same
  90. 3:31strategy or different ones for example
  91. 3:34let's say i want to trade the same
  92. 3:35strategy for both btc usdt and eth usct
  93. 3:40i already have the first route for btc
  94. 3:43now i have to create another trading
  95. 3:45route
  96. 3:46for eth usdt
  97. 3:49the time frame could be anything but i
  98. 3:50still want the 15 minutes and the
  99. 3:52strategy could also be anything but in
  100. 3:55this case i only have one strategy and
  101. 3:57it should work fine for both of them
  102. 4:00instead of adding a new trading route i
  103. 4:02could just duplicate the existing one
  104. 4:04and change the symbol so let's delete
  105. 4:06this one
  106. 4:08and this time
  107. 4:10i'll duplicate the existing one and
  108. 4:12enter the symbol to be eth usct and now
  109. 4:16the time frame exchange and strategy are
  110. 4:18all the same as the first route
  111. 4:25one of the cool features of jesse is
  112. 4:26that you're not limited to using one
  113. 4:28time frame only you can use multiple of
  114. 4:30them and you don't even have to worry
  115. 4:32about look-ahead bias either this is the
  116. 4:35chart of btc usdt on the 15-minutes time
  117. 4:38frame which is what we were trading on i
  118. 4:40also added the indicators that we had
  119. 4:42inside our strategy which are the emas
  120. 4:45with the periods of 21 and 50. our entry
  121. 4:48rule was to open a long position
  122. 4:50whenever the short ema crosses the long
  123. 4:52ema in other words whenever the blue
  124. 4:54line goes above the green line in some
  125. 4:57cases like in this one we're going to
  126. 4:58face false breakouts the blue line is
  127. 5:01above the green line but is so fresh
  128. 5:03that it probably wasn't a good idea to
  129. 5:05open a position just yet a simple way
  130. 5:07for filtering out these subs of false
  131. 5:10breakouts is by simply using a bigger
  132. 5:12time frame for determining the bigger
  133. 5:14trend of the market the right chart is
  134. 5:16the bitcoin price in the hourly time
  135. 5:18frame and the left one is the one with
  136. 5:20the 15 minutes which is what we were
  137. 5:22trading on as you can see here even
  138. 5:24though the crossover happened on the 15
  139. 5:26minutes time frame the right chart which
  140. 5:28is the hourly time frame is not showing
  141. 5:30an uptrend so if we could use the hourly
  142. 5:32time frame as some kind of filtering
  143. 5:34indicator this would not have happened
  144. 5:37so we can say we have a short term and a
  145. 5:39long term trend so i'll define a new
  146. 5:42property called
  147. 5:44short trend
  148. 5:45and i'll copy and paste from what we had
  149. 5:47earlier except that now instead of
  150. 5:50returning true i will return
  151. 5:52one for an uptrend
  152. 5:55and
  153. 5:56minus one for any other situation and
  154. 5:58i'll modify what we had before to use
  155. 6:01this new property
  156. 6:04and also use it for exiting trades all
  157. 6:07right now that we have the trend for the
  158. 6:08left chart which is the 15 minutes time
  159. 6:11frame i need to define the code for the
  160. 6:13hourly time frame which is the right
  161. 6:15chart
  162. 6:16i'm gonna copy the short trend
  163. 6:19paste it here
  164. 6:21and rename it into
  165. 6:23long trend
  166. 6:24the difference is of course about the
  167. 6:26candles before i was passing them by
  168. 6:28using the self.candles property which
  169. 6:31gives me the candles for the current
  170. 6:33trading time frame which in our case is
  171. 6:3515 minutes to get them for the hourly
  172. 6:37time frame i need to specifically ask
  173. 6:40for them to do that i'll be using the
  174. 6:42get candles method the first parameter
  175. 6:44is the exchange which i will pass in the
  176. 6:46current exchange as for symbol i will
  177. 6:49pass in the current trading symbol which
  178. 6:51is btc usdt
  179. 6:54and as for the time frame instead of
  180. 6:56passing it as self.timeframe which gives
  181. 6:59me the current trading timeframe i will
  182. 7:01specifically ask for the hourly time
  183. 7:03frame and then i will repeat this for
  184. 7:06the long ema as well
  185. 7:08and we should be good so once again the
  186. 7:10only difference between long trend and
  187. 7:13short trend is the candles for the short
  188. 7:15trend i'm using self.candles which gives
  189. 7:18me candles for the current trading time
  190. 7:20frame and symbol which in this case is
  191. 7:2215 minutes and btc uct and for the long
  192. 7:25trend i'm using get candles which allows
  193. 7:27me to specifically ask for a certain
  194. 7:29time frame and symbol in this case i'm
  195. 7:31asking for the hourly time frame now
  196. 7:33that i have this new indicator ready i
  197. 7:35can use it inside my interview rule so
  198. 7:37inside my shoot long method i'm gonna
  199. 7:39add and
  200. 7:41self.long trend
  201. 7:43equals one all right let's run another
  202. 7:45back test and this time i should get an
  203. 7:47error saying that the below route is
  204. 7:49missing from my routes that's because
  205. 7:51even though we are using the hourly time
  206. 7:53frame inside our strategy we didn't tell
  207. 7:56jesse about it to do that i'll have to
  208. 7:58add an extra route which is identical to
  209. 8:01a trading route with only one difference
  210. 8:03it doesn't accept any strategy for our
  211. 8:05case i have to choose the same exchange
  212. 8:08which is binance spot
  213. 8:10and the symbol will again be btc usdt
  214. 8:13but the time frame has to be the hourly
  215. 8:16time frame and again there is no
  216. 8:18strategy for an extra route
  217. 8:20now if i run the back test again this
  218. 8:22time it should go through
  219. 8:29let's say we were to backtest our
  220. 8:31strategy for each usdt instead of btc in
  221. 8:34this case looking at the chart of
  222. 8:36ethereum alone is probably not the best
  223. 8:38idea it is a known fact that the btc
  224. 8:40price moves the whole crypto market so
  225. 8:42it's probably a good idea to use this
  226. 8:44data as some kind of confirmation before
  227. 8:46entering trades
  228. 8:48i'm gonna copy the code for short trend
  229. 8:51paste set and rename it into
  230. 8:55btc short trend
  231. 8:58and just like before i have to replace
  232. 9:00self.handles with self.getcandles
  233. 9:04which allows me to specifically pass in
  234. 9:06the exchange the symbol which in this
  235. 9:09case
  236. 9:10instead of passing self.symbol i will
  237. 9:12pass in
  238. 9:13btc usdt
  239. 9:16and then the time frame which in this
  240. 9:18case i want it to be my trading time
  241. 9:20frame so i just pass it by self.time
  242. 9:22frame and i'll do the same for this
  243. 9:25variable
  244. 9:27and inside the shoot long method i will
  245. 9:29add and self.btc short trend equals one
  246. 9:35and if i run the back this again i
  247. 9:37should get an error saying that
  248. 9:39the route for btc usdt is missing that's
  249. 9:43because i've only told you see about the
  250. 9:45routes for each usdt so now i have to
  251. 9:48define a new one for btc usat that is
  252. 9:51going to be an extra route
  253. 9:53with the time frame of 15 minutes which
  254. 9:56is my trading timeframe and the symbol
  255. 9:59will be btc usdt now if i run it again
  256. 10:03it should work
  257. 10:05alright that's it in the next video
  258. 10:06we're gonna talk about how to import
  259. 10:08candles and explain the concept of
  260. 10:10warm-up candles in jesse
  261. 10:17[Music]

About this transcript

This page contains the full transcript of 1. Routes - Algo trading from scratch with Python by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 1,709 words across 261 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.