YouTube2Text

AI Trading Using Machine Learning (Step-by-Step) — Transcript

by Algo-trading with Saleh · 7,654 words · 1,046 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Hey guys, so that. I'm going to show you
  2. 0:01how to use machine learning for trading
  3. 0:04in Python [music] and we're going to
  4. 0:05start from the very beginning. You don't
  5. 0:07have to be an expert and you wouldn't
  6. 0:08believe how easy it is. But I'm not
  7. 0:10going to lie to you. There are some
  8. 0:12caveats and problems when using machine
  9. 0:14learning in trading, but that brings me
  10. 0:16to the best part of the video, which is
  11. 0:18not only I'm going to show you the
  12. 0:19implementation, but I will show you a
  13. 0:21clear path for moving on so that you can
  14. 0:24keep going on till you get the results
  15. 0:25that you want. Now to get to this point,
  16. 0:27I had to do a lot of research and in try
  17. 0:29a lot of different implementations to
  18. 0:31get to this point. And one book which I
  19. 0:33found really helpful was called Advances
  20. 0:35in Financial Machine Learning by Marcos
  21. 0:37Lopez and I made it really easy to
  22. 0:39implement his concepts. I'm going to
  23. 0:40show you what I mean by that in a
  24. 0:41minute. All right, if all that sounds
  25. 0:43good, let's get right to it.
  26. 0:47All right, so let's spend a minute and
  27. 0:48talk about what is machine learning in
  28. 0:50the first place. Now machine learning is
  29. 0:52a way for the computer to learn from
  30. 0:54some patterns in order to predict
  31. 0:56something. Now if that sounds confusing,
  32. 0:58don't worry. But for now, just know that
  33. 1:00it is the opposite of setting some
  34. 1:02rules, which is what we usually do. So
  35. 1:03let me show you that with an example. So
  36. 1:05suppose we want to define a very simple
  37. 1:07function in Python which just adds two
  38. 1:09number, all right? So we would say
  39. 1:11something like this. So define some
  40. 1:14function and it's going to take two
  41. 1:17parameters and it's going to return A
  42. 1:20plus B. And if I were to use this
  43. 1:22function,
  44. 1:23I would simply do this. So 1 plus 2 and
  45. 1:27and let's, you know, print the values of
  46. 1:29it. So now if I go ahead and just run
  47. 1:32this file, I would get number three,
  48. 1:34right? So again, nothing fancy. But what
  49. 1:38if in a very special scenario, we did
  50. 1:41not know this logic. So we didn't know
  51. 1:44that to sum up two numbers, you're going
  52. 1:46to have to use this very special
  53. 1:48character to make it happen. So maybe it
  54. 1:51was something complex, right? If we were
  55. 1:53to use machine learning to solve this
  56. 1:55problem, to be able to add two numbers.
  57. 1:57Instead of this, we would have had to
  58. 1:59have some numbers. So, first we're going
  59. 2:01to have to prepare some values. So, for
  60. 2:04example, if the first two values, which
  61. 2:06is one and two, and the third one, which
  62. 2:09was the result, was three, well, we're
  63. 2:12telling the model, "Okay, so one and two
  64. 2:15equals three." Okay, but this one is not
  65. 2:17enough, right? So, we could give it
  66. 2:19another one. So, three and four, and
  67. 2:21then the third one is going to be what?
  68. 2:23Seven.
  69. 2:24And then we can again repeat. So, two
  70. 2:27and three, and the result is going to be
  71. 2:29five. And even my autocomplete, the one
  72. 2:31that I have on my editor, is learning
  73. 2:33this very fast, right? So, if I give it
  74. 2:35like Actually, no, it's a bit dumb. So,
  75. 2:370 + 9 equals again 9.
  76. 2:40And 0 by 0 equals 0. Okay, so this one's
  77. 2:44good. 1 + 6 = 7. So, you see, even the
  78. 2:47autocomplete on my machine is learning
  79. 2:50learning this very fast. So, now imagine
  80. 2:52if, instead of like seven or eight
  81. 2:54examples, I had like 1,000 examples.
  82. 2:57What machine learning does is that
  83. 2:59you're going to feed it these values,
  84. 3:01and it's going to give you this
  85. 3:04function. Although what gives you, it
  86. 3:06doesn't actually have these values, all
  87. 3:09right? So, it's just going to be the
  88. 3:11result of it. So, it's going to be a
  89. 3:12function called whatever, in this case
  90. 3:15like some funk.
  91. 3:16And this function is going to be able
  92. 3:19that when you give it a value such as
  93. 3:21like five and six or seven,
  94. 3:24it's going to give you
  95. 3:26the number 12. Without actually knowing
  96. 3:29the logic behind it, because it learned
  97. 3:32from the examples that you gave it. All
  98. 3:34right, so this makes sense. But what
  99. 3:37about in trading? Like, what are we
  100. 3:39going to try to learn and what? So,
  101. 3:41usually we we want to follow some exact
  102. 3:44and clear entry and exit rules for the
  103. 3:46strategy. So, for example, we want to
  104. 3:48say, "If the RSI is above this value,
  105. 3:50and the EMA crosses like the other EMA
  106. 3:52line, which is like faster or slower,
  107. 3:55and then we want to buy or open a long
  108. 3:56position. And then if the opposite of
  109. 3:58this happens, then the trend is against
  110. 4:00us and we want to look liquidate the
  111. 4:02position or exit it in other words. So,
  112. 4:04we have to have these indicator values
  113. 4:06in order to define these rules. And we
  114. 4:08also need to know these rules. But the
  115. 4:10problem is that so many people are
  116. 4:12following the exact same rule. So, for
  117. 4:13example, if you try to use something
  118. 4:15such as the RSI or the Bollinger Bands,
  119. 4:17let's say alone and that one single
  120. 4:19indicator, at this point the edge of it
  121. 4:22is mostly gone because so many other
  122. 4:25people know about this, right? So, like
  123. 4:27we know how many people just use
  124. 4:28TradingView. But what if you were to use
  125. 4:30some new data? So, for example, the
  126. 4:33funding fee of the exchange or the
  127. 4:34volume, things that not as many people
  128. 4:36use or any other kind of alternative
  129. 4:39data that you know has some kind of
  130. 4:41predictive power or at least you can
  131. 4:43guess that it does. But you cannot put
  132. 4:45it into words, like you cannot write an
  133. 4:47exact rule for it
  134. 4:50or cannot find a profitable one. Well,
  135. 4:52what if you could search through the
  136. 4:54data and just find something that
  137. 4:57actually works? Well, machine learning
  138. 4:59can do that for us. But what kind of
  139. 5:01features do you want to use? Well, in
  140. 5:03the case of trading, we could use
  141. 5:05anything. It could be some kind of
  142. 5:07indicator value such as the RSI or the
  143. 5:09EMA. It could be the volume, which again
  144. 5:12to me personally is never easy to use
  145. 5:14with an indicator, but with machine
  146. 5:16learning that is very different. It
  147. 5:18could be the time, like what time of the
  148. 5:20day it is, which day of the week we are
  149. 5:22in, which part of the month are we in,
  150. 5:24or the weekend or the beginning of every
  151. 5:26week. So, we know that these days are
  152. 5:29going to be different. But how are you
  153. 5:31going to use that with an indicator? But
  154. 5:33again, with machine learning you could
  155. 5:34just feed it into the model and maybe,
  156. 5:37just maybe, it can find a good pattern.
  157. 5:39All right, but the next question is what
  158. 5:42should the model try to predict? Like
  159. 5:44what exactly? Because the simplest one
  160. 5:46that comes to mind is the price, right?
  161. 5:48Well, actually, if you ask people who do
  162. 5:51this thing properly or successfully, if
  163. 5:55you look them up, they're going to tell
  164. 5:56you trying to predict the price is the
  165. 5:58hardest thing to do. So, there are much
  166. 6:00easier ways to use machine learning.
  167. 6:03Now, predicting the price, yes, it is
  168. 6:05one way to use it. Another way is to
  169. 6:08find a way to set the position sizing of
  170. 6:10your position. Another way is to simply
  171. 6:12use it as some sort of filter, like is
  172. 6:15this trade that I'm I'm actually about
  173. 6:17to take, is it profitable or not? If the
  174. 6:19model says it is, I'm going to take it.
  175. 6:21If it says it's not, I will not take it.
  176. 6:23And by doing this, we're going to
  177. 6:25improve our win rate. So, this is
  178. 6:26another type to do it. But, one which is
  179. 6:29very simple and handy, and what we're
  180. 6:32going to try in this video, is to simply
  181. 6:35try to predict the direction of the
  182. 6:37price. So, not the exact price, but the
  183. 6:39direction of it, like whether it's going
  184. 6:41up, whether it's going down, or whether
  185. 6:43it's in a sideways. And if I want to
  186. 6:46take, let's say, long positions, of
  187. 6:48course, I will only take it if the model
  188. 6:50says that the price is about to go up.
  189. 6:52So, that's it. I will only try to
  190. 6:53predict the direction of the price. So,
  191. 6:55for an uptrend, it will just give me
  192. 6:57one. For a downtrend, it will give me
  193. 6:59minus one. And for a sideways, it will
  194. 7:00give me zero. So, basically, like any
  195. 7:03kind of indicator that I would usually
  196. 7:05use in a strategy for the direction of
  197. 7:07the trend. Now, in machine learning,
  198. 7:09because we only have three types of
  199. 7:11outputs, this is called a classification
  200. 7:13problem. Now, another way you might have
  201. 7:15heard about a classification problem in
  202. 7:17machine learning is when you train a
  203. 7:18model to simply tell you if in this
  204. 7:21photo, is this a cat, is it a dog, or is
  205. 7:23it a human, for example. So, in this
  206. 7:26case, if you only expect three these
  207. 7:28outputs, it's going to be again a
  208. 7:30classification problem with three
  209. 7:32outputs only. Now, of course, this was a
  210. 7:34super simplification way of putting
  211. 7:36things. But, before I move on to the
  212. 7:38code, I want to talk about something
  213. 7:40really important. So, even if you are
  214. 7:42already with machine learning, I'm
  215. 7:44betting that this has been a really big
  216. 7:47problem for you. For me personally, this
  217. 7:49was the very reason why I tackled this
  218. 7:52thing way later than what I should have.
  219. 7:54All right. Now, this is the best part of
  220. 7:56the video because even if you have used
  221. 7:58machine learning in the past
  222. 7:59successfully in other fields, you're
  223. 8:01going to need it because I'm going to
  224. 8:02show you a solution that I found to a
  225. 8:05big problem. Now, what's the big
  226. 8:06problem? Well, you see, when you want to
  227. 8:08use machine learning for a simple
  228. 8:09problem such as detecting whether the
  229. 8:11photo is a dog or a cat. You simply feed
  230. 8:13it, let's say, thousands of photos, and
  231. 8:15that's it. The model can predict it
  232. 8:17pretty well with a very good accuracy.
  233. 8:18Or even when the model is trying to
  234. 8:20learn to play a game in the case of
  235. 8:22reinforcement learning, which you don't
  236. 8:24have to know what exactly it is, but my
  237. 8:26point is if you have a problem that is
  238. 8:29simple, it doesn't change, or in other
  239. 8:31words, in technical words, it is a
  240. 8:33stationary, then it is very easy to
  241. 8:35train a model. But in finance, we're
  242. 8:37dealing with random data, random noise,
  243. 8:40and markets which are changing all the
  244. 8:42time. And even different markets usually
  245. 8:45behave differently. So, often times you
  246. 8:47write a strategy, let's say, for BTC,
  247. 8:49but when you try to trade the same
  248. 8:50strategy on an altcoin such as, let's
  249. 8:52say, SOL USDT, you find out that it
  250. 8:55doesn't work at all. That's a really a
  251. 8:56scary problem, which means the accuracy
  252. 8:58of your model it's it's not going to be
  253. 9:00like 99%. It might be 60%. It might be
  254. 9:03significantly lower. Now, we all know
  255. 9:05this problem exist, but as I said, even
  256. 9:07if you get accuracy of, let's say, 60%,
  257. 9:10it's good, right? Like especially if
  258. 9:12strategy has a win rate of, let's say,
  259. 9:1340%, and then out of nowhere a model can
  260. 9:16have an accuracy of 60% just to know if
  261. 9:18the trades are profitable or not, that's
  262. 9:20going to be huge. But,
  263. 9:22here's the problem that I didn't have a
  264. 9:24solution for. You see, suppose I write
  265. 9:27my implementation, and I feed it some
  266. 9:29data. Now, it could be any data, let's
  267. 9:31say, just price data and volumes and
  268. 9:33some indicator values, the things that
  269. 9:35we easily have, not some alternative
  270. 9:37data such as the funding fees or things
  271. 9:39like that, okay? Now, suppose that I'm
  272. 9:41not getting good results. I'm getting
  273. 9:43negative results. Like my strategy isn't
  274. 9:45profitable. So, yes, we are getting the
  275. 9:48direction of the trend using this model
  276. 9:50which I'm about to train, but how should
  277. 9:52I know the problem is with my model or
  278. 9:55with the implementation that I've done?
  279. 9:57So, I thought about this question for a
  280. 9:59long time and like I said, I postponed
  281. 10:01machine learning altogether until I came
  282. 10:04up with a solution. In programming, we
  283. 10:06have this concept called TDD, which it
  284. 10:08stands for test-driven development. So,
  285. 10:11let me show you very quickly what that
  286. 10:12means in case you're not a super
  287. 10:14developer or you had to you just haven't
  288. 10:16heard about this. All right, so let's
  289. 10:18copy everything we had before. Okay, so
  290. 10:21you remember this example that I gave
  291. 10:23earlier? So, 1 + 2 = 3, 3 + 4 = 7, 2 + 3
  292. 10:28is supposed to be like 5. Now, if you
  293. 10:31want to implement this using TDD or
  294. 10:33again, test-driven development in
  295. 10:35Python, first we would have to write the
  296. 10:37test and then we would write the
  297. 10:39implementation. So, here's the example.
  298. 10:41So, I'm going to write a simple test
  299. 10:43function first, all right? So, I'm going
  300. 10:45to call it test some function and in it,
  301. 10:48I will say assert that some function
  302. 10:52when I give it 1 and 2, the result is
  303. 10:53going to be 3.
  304. 10:55We can also test for other scenarios
  305. 10:58because let's say the function is
  306. 11:00supposed to get one of them right, but
  307. 11:02just in case, I want to add some other
  308. 11:04scenarios, right? So, again, now, 3 and
  309. 11:074 = 7. All right, so it wrote these
  310. 11:10based on these examples that we had
  311. 11:11before. Very clever, actually. So, if I
  312. 11:14just do it one more time, yes, this is
  313. 11:16correct and so is this one. All right,
  314. 11:19so now we have all these examples here,
  315. 11:21right? You see we're getting an error
  316. 11:23here because we haven't defined the
  317. 11:25function yet. So, that was my point. So,
  318. 11:26first we define the test and then we
  319. 11:28define the function. Now, it doesn't
  320. 11:30really matter, but my point is that
  321. 11:32we're to have to have tests for it,
  322. 11:34right? So, now
  323. 11:36I can write the function itself. So, def
  324. 11:39and some function. When I give it A and
  325. 11:42B, it should return A plus B. And now
  326. 11:44we're not getting an error anymore,
  327. 11:46right? Now, just for this to make a
  328. 11:48little bit more sense, let's duplicate
  329. 11:49this line and comment these. And now,
  330. 11:53let's say I was going to say that 1 + 2
  331. 11:56does not equal 3. It equals, let's say,
  332. 11:585. Right? So, we know that this is
  333. 12:00incorrect, right? Now, we know this
  334. 12:02because we humans can easily sum up two
  335. 12:05integer numbers. That's very easy for
  336. 12:06us. But again, imagine that this is a
  337. 12:08super complicated function. So, it's not
  338. 12:11a simple one, and we don't know what
  339. 12:13it's supposed to return. But, now that
  340. 12:15we're trying to use TDD to write this,
  341. 12:17we know that the sum of 1 and 2 equals
  342. 12:213. So, we know that 5 is incorrect,
  343. 12:24right? So, I'm going to run this file by
  344. 12:26simply saying pytest tdd.py. Now, it
  345. 12:28doesn't matter what pytest is. Just
  346. 12:30forget about it. The point is it's how I
  347. 12:33am executing this, and I just want to
  348. 12:35show you the concept, okay? So, if I run
  349. 12:36this, it's going to tell me that it's a
  350. 12:38fail. And it is saying that 3 does not
  351. 12:42equal 5. So, this is what we were
  352. 12:43expecting, right? So, 3 should equal 5,
  353. 12:45but it doesn't. So, it is failing. So,
  354. 12:48if I comment this and bring these back,
  355. 12:51which are the correct values, and run
  356. 12:53this one more time, it's going to give
  357. 12:54me a pass. Now, forget these warnings,
  358. 12:56okay? So, it's giving me a pass. So, now
  359. 12:58that I'm getting a pass, I can be sure
  360. 13:01that my implementation of summing two
  361. 13:03integer values is correct. Why? Because
  362. 13:06all these tests are passing. Now, what
  363. 13:09if we did the same thing in machine
  364. 13:11learning? Well, if you run a test for
  365. 13:13it, and then it passes, then I can
  366. 13:17easily run a back test or deploy it for
  367. 13:19life. And if it doesn't work, I can be
  368. 13:22sure that my machine learning
  369. 13:24implementation is correct, and the
  370. 13:26problem is from somewhere else. Maybe
  371. 13:29it's in my position sizing, risk
  372. 13:31management, maybe it's in my exit rules
  373. 13:33of the strategy, or any other part of
  374. 13:35it. But, if it failed, if the unit test,
  375. 13:37or whatever kind of test that you want
  376. 13:39to call it, if that test failed, I can
  377. 13:41be sure right there that my
  378. 13:43implementation is incorrect. Then, I can
  379. 13:45dig further. Maybe the data that I'm
  380. 13:47feeding is incorrect, maybe the features
  381. 13:49are incorrect, maybe the labeling way
  382. 13:51that I'm doing is incorrect. Whatever,
  383. 13:53it doesn't matter. The point is I can
  384. 13:55know exactly where I should look for the
  385. 13:58problem to solve it. Now, I hope this
  386. 14:00all made sense to you, and I don't know
  387. 14:03about you, but as someone who has
  388. 14:04struggled with this concept, this simple
  389. 14:07solution that I just explained, it
  390. 14:09changed everything for me. So, in the
  391. 14:11rest of the video, yes, I'm going to
  392. 14:13implement things, but we're also going
  393. 14:15to test it, and that's the really
  394. 14:17important part. All right, so now that
  395. 14:19I've explained these concepts, I can
  396. 14:21move on to the actual strategy. Now, as
  397. 14:23always, I'm going to use the Jesse
  398. 14:24framework, which just recently added the
  399. 14:26machine learning and stuff, and you kind
  400. 14:28of see how easy it makes it for both
  401. 14:31training the model and deploying it for
  402. 14:33back test, live trading, or whatever
  403. 14:35that you want to do. All right, so,
  404. 14:37we're going to have one script to
  405. 14:39collect the data and train it, and then
  406. 14:42run the actual back test, and we're
  407. 14:44going to have the strategy file itself,
  408. 14:46which is basically the one you guys care
  409. 14:48the most. So, let's begin with that one.
  410. 14:50So, you see, here we have a simple
  411. 14:52strategy class, which is inheriting from
  412. 14:54the strategy class of Jesse. Now, if you
  413. 14:56have watched my previous videos or
  414. 14:58familiar with this framework even a
  415. 15:00little bit, you already know what these
  416. 15:02are and what type of properties it gives
  417. 15:04you in order to write a strategy, which
  418. 15:06makes it really easy. Now, we also have
  419. 15:08some comments here, which will describe
  420. 15:09the strategy's logic if you want to go
  421. 15:11through that. But, for now, let's just
  422. 15:13talk about what we are trying to predict
  423. 15:16here, okay? So, the method that we're
  424. 15:18trying to use here is called the triple
  425. 15:20barrier vertical method, okay? Now, I
  426. 15:23got this concept from the book that I
  427. 15:26mentioned in the beginning of the video.
  428. 15:27So, you could go and give it a watch,
  429. 15:29but it's actually super simple and the
  430. 15:32book didn't really add anything except
  431. 15:34just maybe one thing or maybe it made it
  432. 15:36a little bit clearer for me. Now, what
  433. 15:38is it? Well, we simply try to predict
  434. 15:41that n bars from now, if the price is
  435. 15:43going to be higher, lower, or if it's
  436. 15:47going to almost stay the same or in the
  437. 15:50concept of trading, are we going to be
  438. 15:52in a range market? Now, why is this
  439. 15:54important? Because usually when we open
  440. 15:56a position, like assuming that we only
  441. 15:58have one entry and one exit, the entry
  442. 16:01could, let's say, be done by a market
  443. 16:03order. Nothing fancy. But, the exit
  444. 16:06could happen with either a stop-loss
  445. 16:08order or a take profit, which is usually
  446. 16:10a limit order, right? And let's say it's
  447. 16:12a long position, all right? So, if the
  448. 16:14upper barrier or, you know, the higher
  449. 16:16line is touched first, we're going to
  450. 16:18say, "Okay, so this is a plus one." As
  451. 16:21if the direction of the trend is toward
  452. 16:22up or, in other words, we are in an
  453. 16:24uptrend. And if the stop-loss is going
  454. 16:27to be touched first, meaning that we're
  455. 16:28going to lose money, then this model is
  456. 16:30supposed to return minus one. In other
  457. 16:32words, it's saying that, "Hey, maybe
  458. 16:34we're in a downtrend, so don't take any
  459. 16:36long positions." And if it returns zero,
  460. 16:38it means that our vertical barrier is
  461. 16:41being touched first. Now, what is a
  462. 16:42vertical barrier? Well, you see, I said
  463. 16:44that after n bars, okay? So, we need to
  464. 16:46have some kind of box. So, suppose that
  465. 16:48we open the position
  466. 16:50right now. Now, n bars from now, now n
  467. 16:52could be any number, such as, let's say,
  468. 16:5410 bars. All right? So, 10 candles from
  469. 16:57now, what is going to be the price?
  470. 16:59Like, are we going to touch the upper
  471. 17:01barrier first or the lower barrier
  472. 17:03first? Or, if we're not going to touch
  473. 17:05either of them, we're going to consider
  474. 17:07it a range market and in that case we're
  475. 17:09going to return zero, because we have to
  476. 17:11have some kind of window, right? So, we
  477. 17:13cannot, like, open the position and wait
  478. 17:15like three months for a simple scalping
  479. 17:17strategy. It doesn't make sense. So,
  480. 17:19there has to be some kind of window. And
  481. 17:21we're going to have to define the
  482. 17:22window. And in this example, I defined
  483. 17:25it the number 50, which you can find
  484. 17:27here. So, feel free to change it however
  485. 17:29you like. But basically, so that's what
  486. 17:31we're trying to predict, right? So, it's
  487. 17:32a simple classification problem, and it
  488. 17:35either gives us minus one, plus one, or
  489. 17:38zero. That's it. Let's move on to the
  490. 17:40other parts of the strategy, starting
  491. 17:41with the before function, which is
  492. 17:44basically the one that you're going to
  493. 17:45use especially with the type of machine
  494. 17:48learning that we are using in this
  495. 17:50strategy, which is the triple barrier
  496. 17:52method. Okay. Now, we're simply saying
  497. 17:54that if you are in the gather mode,
  498. 17:55return because if we are in the deep
  499. 17:57play mode, we don't want to do the
  500. 17:59training and stuff that we're going to
  501. 18:00do right now. We just want to use the
  502. 18:02model, okay? Which we're going to cover
  503. 18:04later. All right. So, we're simply
  504. 18:06saying that if you haven't recorded
  505. 18:07anything yet, let's record the features,
  506. 18:10which I'm going to show you how that is.
  507. 18:12And then we are setting the upper
  508. 18:14barrier, the lower barrier, the index,
  509. 18:18the index that we started doing this,
  510. 18:20which is right now. And we simply give
  511. 18:22it the current index by simply saying
  512. 18:24self.index because that's a built-in
  513. 18:26property of Jesse. And then we're going
  514. 18:28to say, "Okay, so features have been
  515. 18:30recorded." So, this is this flag. And
  516. 18:31what it does is that on the next candle,
  517. 18:34we're not going to go through this.
  518. 18:35Okay? Not until at least like we have
  519. 18:38successfully recorded one whole you know
  520. 18:40record for machine learning. Now,
  521. 18:42starting the next candle, we're going to
  522. 18:44go here, right? So, we're saying, "Okay,
  523. 18:46has the upper barrier been touched?" And
  524. 18:49to do that, we're saying, "Okay, if the
  525. 18:51current price is above it, then it's
  526. 18:52been touched." We do the opposite for
  527. 18:54lower barrier. And then for the
  528. 18:56vertical, we're using the time. So,
  529. 18:58we're saying, "If the current index
  530. 18:59minus the recorded index, which we
  531. 19:01recorded here, is more than the vertical
  532. 19:03barrier, which we set it to number 50,
  533. 19:06if you remember." Okay, so it was here.
  534. 19:08Again, this could be any number that you
  535. 19:09want. And we're saying, "If the upper
  536. 19:11barrier have been touched or the lower
  537. 19:13one or the vertical, then the label is
  538. 19:16going to be one if it was the upper
  539. 19:18barrier. It's minus one if it was the
  540. 19:20lower barrier and it's zero if it was
  541. 19:23the vertical, okay? And then we are
  542. 19:25using self.record_label
  543. 19:27function of Jesse to record it. And
  544. 19:29we're giving it a name, which could be
  545. 19:30anything you want. And we're setting the
  546. 19:32value, which again is either 1, -1, or
  547. 19:350. And then we reset these flags, okay?
  548. 19:37So, nothing fancy. So, so far you have
  549. 19:41used two functions for machine learning.
  550. 19:43One is the record features, which is
  551. 19:45where we basically give the inputs of
  552. 19:47the model, and second is the record
  553. 19:50label, which is where we get the output
  554. 19:52of the model. Although, because we are
  555. 19:54in the training mode right now or gather
  556. 19:56mode as we are calling it here, we have
  557. 19:58to feed the output to the model. So,
  558. 20:00that's the thing. When we are in the
  559. 20:01gather mode or training mode, we have to
  560. 20:03feed the model both the input and the
  561. 20:05output. But, when we are in the deploy
  562. 20:07mode, that's when we're going to say,
  563. 20:09"Okay, here's the input. Now, give me
  564. 20:11the output. Predict the output." So,
  565. 20:13that's what machine learning does, all
  566. 20:14right? Now, what are the features that
  567. 20:16we are feeding it? So, the features are
  568. 20:18here. So, this is the function that you
  569. 20:20have to define in your machine learning
  570. 20:21in Jesse. And this has to be the exact
  571. 20:23name of it. And what it does is it
  572. 20:26simply returns a dictionary. Now, in
  573. 20:28here, these are the things that I have
  574. 20:29defined and, you know, I'm explaining it
  575. 20:32a little bit here in the comments. It
  576. 20:33doesn't matter. But, the point is we are
  577. 20:35defining the ATR, the current price, the
  578. 20:37EMA 9, 21, 50, the recent close numbers,
  579. 20:42the Keltner indicator, and some things
  580. 20:44like that. But, if you notice, I'm not
  581. 20:46just passing these values because they
  582. 20:47are not stationary, I'm turning them
  583. 20:50stationary first and then I'm using
  584. 20:52them. So, for example, here instead of
  585. 20:53simply the ATR, I'm saying ATR divided
  586. 20:56by the current price. Instead of simply
  587. 20:57the EMA 21, I'm saying 21 minus 50
  588. 21:00divided by EMA 50. So, I'm giving it a
  589. 21:02ratio. Because these values are
  590. 21:05stationary. But, if again, if I simply
  591. 21:07give it the price or the EMA, which also
  592. 21:10looks like the price, it's not going to
  593. 21:11be a stationary. Now, by the way, I made
  594. 21:12a whole page on our documentation about
  595. 21:15the stationary and why that is
  596. 21:16important. So, definitely make sure to
  597. 21:18check it out. Anyways, so we are
  598. 21:20returning a dictionary of values. So,
  599. 21:22those are my inputs and again, my
  600. 21:24output. So, that's it. That's all we had
  601. 21:26to do in order to train the model. Now,
  602. 21:29the next part is using it and that's
  603. 21:31also going to be really simple. So, for
  604. 21:33using the strategy, we're going to use
  605. 21:35the typical Jesse functions, the should
  606. 21:37long, should short, which are used to
  607. 21:39know whether or not we want to open a
  608. 21:41long or short position. So, basically,
  609. 21:42the entry rules of the strategy. And in
  610. 21:44it, we are simply saying that if you are
  611. 21:46in the gather mode, return false. So,
  612. 21:48because we don't want to be recording
  613. 21:49any trades in the gather mode or
  614. 21:52training phase. And again, this is just
  615. 21:54for this type of machine learning. For
  616. 21:55another one, for example, if you want to
  617. 21:58know if your trade is going to be
  618. 21:59profitable or not, you actually want to
  619. 22:00take trades and that's going to be the
  620. 22:02data that you're going to train the
  621. 22:03model on. But, in the triple barrier
  622. 22:06method, which we are simply trying to
  623. 22:08predict the direction of the trend, we
  624. 22:11don't want to be taking any trades. All
  625. 22:12right, so in it, we're simply saying the
  626. 22:14probs or probabilities is going to be
  627. 22:16self.ml.predict_probability.
  628. 22:19And this is a built-in function of
  629. 22:20Jesse. So, it makes it super simple. So,
  630. 22:23basically, assuming we already have the
  631. 22:24model, this is all I have to run in
  632. 22:27order to take it. And now, I have both
  633. 22:30the probability of the price going up
  634. 22:32and it going down. Now, I could also get
  635. 22:34it, you know, being in the vertical, but
  636. 22:36I don't need it here, so that's why I'm
  637. 22:37not using it. But, the entry rule of the
  638. 22:40strategy is going to be, so if the
  639. 22:42probability of the price going up is
  640. 22:43bigger than my threshold and if the
  641. 22:45probability of it going up is also more
  642. 22:48than 20% more than probability of it
  643. 22:51going down, then I want to take a long
  644. 22:53position. So, again, this is just
  645. 22:54something I defined. You could play
  646. 22:56around with the numbers. And also, if
  647. 22:57you want to see what's the threshold,
  648. 22:59well, we defined it here, so we set 45%.
  649. 23:01So, we want to know if the model has at
  650. 23:04least,
  651. 23:05you know, a little bit of confidence
  652. 23:07before actually taking a trade. Now,
  653. 23:09this is a test strategy that I'm running
  654. 23:11just to demonstrate how these things
  655. 23:13work, but in a production strategy, you
  656. 23:16probably want to have this condition as
  657. 23:19a secondary or just, you know, one other
  658. 23:22filter for your strategy. So, you
  659. 23:24probably don't want to use it as the
  660. 23:26single point of truth for the entry rule
  661. 23:29of the strategy. And that's it, guys.
  662. 23:31Now, for the short position, we're doing
  663. 23:32the opposite, and this is where we do
  664. 23:34the position sizing, the go long and go
  665. 23:35short method. So, assuming that the
  666. 23:37should long is returning true, we say,
  667. 23:39"Okay, so now let's go long." And if
  668. 23:42that's the case, my entry is going to be
  669. 23:43this price, which we passing the current
  670. 23:45price, in other words, the market order.
  671. 23:48And distance is something that I'm
  672. 23:50calculating here, simply using the ATR,
  673. 23:52and then I'm getting the quantity of it,
  674. 23:55and I'm submitting the buy order, which
  675. 23:56is my entry order, the stop loss, and
  676. 23:58the take profit. Now, usually I submit
  677. 24:01these two in the on open position method
  678. 24:04of Jesse, which is this function where
  679. 24:06it says, "Okay, so now that we have an
  680. 24:08open position, let's submit the exit
  681. 24:10orders," which would be these two, but
  682. 24:12we can also set it here, so this is
  683. 24:14perfectly fine. And that's it. That's
  684. 24:16all that we had to do. So, let's go up,
  685. 24:20and yep, so this is the distance that I
  686. 24:21talked about, which I'm using the ATR,
  687. 24:24and that's it. Like, this was an entire
  688. 24:27strategy for using machine learning in
  689. 24:29Jesse. So, that's how simple it just
  690. 24:32got. But now, let's move on to the
  691. 24:33script, which you're going to have to
  692. 24:35run. Now, in the documentation, I have
  693. 24:38mentioned a couple of scripts and how to
  694. 24:39run them, but here I'm going to leave
  695. 24:41you with one, at least for the triple
  696. 24:43barrier method, and I'm using the TDD.
  697. 24:45Now, what is TDD? Well, I I explain. So,
  698. 24:47basically, we're creating some synthetic
  699. 24:49data, right? Some fake data. So, first
  700. 24:52we have to create that fake data, and
  701. 24:55I'm importing some libraries and also
  702. 24:57the strategy I just showed you guys and
  703. 24:59I'm defining the number of regimes, you
  704. 25:01know, the price regimes that are going
  705. 25:03to change and the total number of
  706. 25:05candles I'm giving it 6 months. The
  707. 25:07exchange I named it test exchange. The
  708. 25:09symbol is test USD and the time frame is
  709. 25:1115 minutes. We are calculating some
  710. 25:13stuff for the one hour candles and so on
  711. 25:15and this is just for the printing output
  712. 25:18and this is where we define the price
  713. 25:20regime. So first we're going to have an
  714. 25:22uptrend, sideway, a downtrend and again
  715. 25:24a sideway and again we're going to
  716. 25:26repeat this whole thing four times which
  717. 25:27will give us four in three
  718. 25:30in total. Now you can also change this
  719. 25:32and 6 months may not be enough and again
  720. 25:34this is just a test one. Feel free to
  721. 25:36change it however you like and then
  722. 25:38here's where we actually generate the
  723. 25:39close data, right? So we're saying that
  724. 25:42okay,
  725. 25:42this is a empty list.
  726. 25:44The starting price is 1,000 and if the
  727. 25:47direction is plus one, we're going to
  728. 25:50add to the price by 2.5. If it's in a
  729. 25:52downtrend, we want to subtract it and if
  730. 25:55it's in a sideway, we are just using a
  731. 25:57sinus method to add to it. And that's
  732. 26:00it. It returns the prices. Now these are
  733. 26:02just for printing stuff, not important.
  734. 26:05And then the first phase which is the
  735. 26:06gather mode, again printing itself
  736. 26:08doesn't matter. We're getting all the
  737. 26:10candles. We are defining the routes
  738. 26:12according to what Jesse expects. So
  739. 26:14we're simply giving it the exchange
  740. 26:16symbol and the candles and we're
  741. 26:18returning the config. The fees are set
  742. 26:20to zero. I'm passing the routes, the one
  743. 26:22hour candles and everything and that's
  744. 26:24it. This is returning the data points.
  745. 26:26In the second phase which is where we do
  746. 26:27the retraining, we're using the train
  747. 26:29model method of Jesse. Now this method
  748. 26:32has been added to the research module of
  749. 26:34Jesse and you have to import it and it
  750. 26:36takes the data and some parameters of
  751. 26:38the estimator or the classifier of the
  752. 26:40machine learning. Now here I'm using the
  753. 26:42random forest classifier and this could
  754. 26:45be anything that you like. It could be a
  755. 26:47support vector machine which actually
  756. 26:48works pretty well especially when the
  757. 26:50number of data that you have is limited,
  758. 26:52or it could be any other type of
  759. 26:54classifier. And this is really
  760. 26:55important. So, not only I made it
  761. 26:57simple, I also made it flexible. So, I
  762. 26:59didn't want to limit you to just like
  763. 27:02one type of machine learning. So, that's
  764. 27:05why you can just pass any kind of
  765. 27:06classifier and it will just work. And
  766. 27:08these are some values that I have
  767. 27:10defined, which help with the model. Now,
  768. 27:12for these values, if you're not sure
  769. 27:13what to set, just ask AI. They are
  770. 27:15really good with these things. But
  771. 27:17especially if you want to prevent the
  772. 27:19overfitting, or if the number of classes
  773. 27:21that you have are not balanced, like
  774. 27:23these values are going to be important.
  775. 27:25And then I'm passing the task, which is
  776. 27:27multi-class. Now, if we only had two
  777. 27:29types, like a true or false kind of
  778. 27:32output, we could have set this to
  779. 27:33binary. And we also have the regression
  780. 27:35type, and we also have the multi-class,
  781. 27:37which could be more than two, like in
  782. 27:40this case, just three classes. And then
  783. 27:42we have the face deploy, which is
  784. 27:43actually where we actually run a
  785. 27:45backtest and see some results to see if
  786. 27:47the model is actually working correctly
  787. 27:49or not. And in it, we're using the
  788. 27:50backtest function of the research module
  789. 27:52of Jesse, which isn't really something
  790. 27:54new. We always had this. Now, this one
  791. 27:56is again for printing stuff, and this
  792. 27:58one is for validating the model, because
  793. 28:00we want to see some metrics in order to
  794. 28:02be sure the model is actually working
  795. 28:04properly, so we don't just run a
  796. 28:06backtest. First, we validate the model,
  797. 28:08and then we run the backtest. And this
  798. 28:09is the main entry of the file, where we
  799. 28:12actually run those face functions that I
  800. 28:14just showed you. So, the data point, the
  801. 28:16training point, then we are validating
  802. 28:19the model. After we get the results,
  803. 28:21then we deploy it to get some backtest
  804. 28:24results, and we print some final stuff.
  805. 28:26So, that's it. And again, I'm going to
  806. 28:29open source this file, so you guys can
  807. 28:30see it and run it for yourself. And now
  808. 28:32we can actually run this by saying
  809. 28:35Python triple barrier, and that's it.
  810. 28:40And as you can see, it's actually pretty
  811. 28:41fast, so it's not going to take a lot of
  812. 28:44time. All right, so a lot of stuff are
  813. 28:45not absolutely necessary, they're just
  814. 28:47some helpful output that we are
  815. 28:49printing. So, for example, the total
  816. 28:50number of bars, the bars per regime, the
  817. 28:53price change, so we started from here
  818. 28:55and went up to this, so it was clear
  819. 28:57uptrend overall. And these are the
  820. 28:58regimes, so the first the uptrend, the
  821. 29:00sideways, downtrend, and you can see
  822. 29:02what the price it started and where did
  823. 29:04it end. Again, nothing that important,
  824. 29:07although it does help you to ensure that
  825. 29:08the data that you generated is correct.
  826. 29:11And here we can see the number of
  827. 29:12features, the strategy, the regimes, and
  828. 29:14things like that. Now, this is the
  829. 29:16backtest results initially, and it says
  830. 29:18no trade were opened, which is what we
  831. 29:21wanted because, like I said, if you are
  832. 29:23in the garden, what we don't want to
  833. 29:24execute any trade, so this is correct.
  834. 29:26And we can also see that what was in
  835. 29:28total number of data points which we
  836. 29:30used for training. It was 1,584,
  837. 29:33and 46% of it was just the output being
  838. 29:37minus one, 42% was one, and 10% of it
  839. 29:41was a clear sideways. All right, so this
  840. 29:43is talking about the data collected, and
  841. 29:45this is talking about data that was
  842. 29:46trained, which is exactly the same
  843. 29:49thing, basically, so
  844. 29:51you don't have to read this again. And
  845. 29:53then we have the feature importance,
  846. 29:55which will tell you which one of these
  847. 29:58features that we used were actually
  848. 29:59helpful. It gives them some kind of
  849. 30:01score, and some F value, so these are
  850. 30:03some standard metrics which are really
  851. 30:05helpful, and here you can also read
  852. 30:07about every single one of them, like
  853. 30:08which one does what. Now, if this isn't
  854. 30:11super clear to you, it doesn't matter
  855. 30:12cuz we have another one which is
  856. 30:14clearer, so let's just skip it for now.
  857. 30:16And here it says the type of the
  858. 30:18classifier we used, and here we can see
  859. 30:20the accuracy of the model and some other
  860. 30:22metrics. And as you can see, it got a
  861. 30:24accuracy of 99.7%,
  862. 30:27which is almost 100%. And this is how I
  863. 30:29know that the model is working. Again,
  864. 30:32the reason we are seeing such a huge
  865. 30:34number of accuracy is because we're
  866. 30:37using synthetic data, fake data in other
  867. 30:39words. But in a real-world scenario,
  868. 30:42there's no way you're going to get this
  869. 30:44good of a result. Okay? And that's
  870. 30:46perfectly normal. But, because we were
  871. 30:48doing TDD, we're creating the tests
  872. 30:50ourselves with fake data just to see if
  873. 30:53the model works or not, we actually
  874. 30:54wanted to have such a high accuracy. So,
  875. 30:57this is expected and this shows that my
  876. 30:59implementation is correct and I'm ready
  877. 31:01to move on to the real prices of the
  878. 31:04market and try to beat the market. And
  879. 31:06if it doesn't work, I can just play
  880. 31:07around with my inputs and things like
  881. 31:08that. But, the implementation itself is
  882. 31:11correct. Now, this also tells me like
  883. 31:13how many times the model predicted that
  884. 31:15it's going to be minus one and how many
  885. 31:16times it was actually, which you can see
  886. 31:18it was this. There was just one case
  887. 31:20where it predicted that it's going to be
  888. 31:22zero, but it was actually minus one. And
  889. 31:24that's why we did not get an accuracy of
  890. 31:26100%. And for the other stuff, it's
  891. 31:30100%. So, it predicted zero and one
  892. 31:32perfectly fine, but for minus one, it
  893. 31:34just got one thing wrong. Now, in a real
  894. 31:36world scenario, you really going to love
  895. 31:38this table. So, it's my favorite,
  896. 31:41actually, cuz it tells you how many
  897. 31:42false and true negatives or false and
  898. 31:45true positives exist with the model.
  899. 31:48Now, if you don't know what that is,
  900. 31:49don't worry about it. Once you get your
  901. 31:51hands dirty with machine learning,
  902. 31:52you're going to hear it all the time.
  903. 31:53Now, we also have some other metrics of
  904. 31:55the model, so we can know for every
  905. 31:57single output, for minus one, zero, or
  906. 31:59one, what was precision, what was the
  907. 32:01recall, and what was the F1. Now, this
  908. 32:03is also really, really important because
  909. 32:05you don't want just the precision of the
  910. 32:08model to be high, like the recall of it
  911. 32:11and the F1 are also important. Now, if
  912. 32:13you don't know these metrics, again,
  913. 32:14look them up because they can be pretty
  914. 32:16helpful. Now, this is that table that I
  915. 32:18said, you know, I'm going to show you
  916. 32:19later and it's super helpful. You know,
  917. 32:21instead of this one, which is might be a
  918. 32:23little hard for some of you guys to
  919. 32:24read, you could just use this. And
  920. 32:26basically, it gives us uh the fact that
  921. 32:29what if we did not use this input? Like,
  922. 32:32what would happen to the accuracy then?
  923. 32:33And based on that, it's going to say if
  924. 32:36this input is actually helping or
  925. 32:38hurting the predictability of your
  926. 32:41model. Now, in this case, we're getting
  927. 32:42the exact same number. It's saying that
  928. 32:44all of them are neutral, so it doesn't
  929. 32:45matter if I drop them or not, and the
  930. 32:47accuracy is not changing, and that's
  931. 32:49because I'm using fake data. But, in a
  932. 32:51real-world scenario, you're not going to
  933. 32:53see this, and for some of them it's
  934. 32:54going to say, "Okay, so these are
  935. 32:55helpful, keep them." And for some of
  936. 32:57them, it's going to say, "Okay, drop
  937. 32:59them because they're actually hurting
  938. 33:01the performance of the model." Because
  939. 33:03you see, in a real-world scenario, you
  940. 33:05shouldn't just give the model as many
  941. 33:07inputs as you can. Because, sure, in
  942. 33:09that case, you could just give it 100
  943. 33:10inputs, right? But, the reality is that
  944. 33:12some of the inputs are not going to be
  945. 33:14helpful. They will actually hurt the
  946. 33:16performance of the model. So, that's why
  947. 33:18you want to run this test, look at this
  948. 33:20table, and if some of them are hurting
  949. 33:22it, you could just remove them, and by
  950. 33:23doing so, you're going to actually get a
  951. 33:25better performance out of your model and
  952. 33:28data. But, because this is going to be
  953. 33:30different per each test, per each market
  954. 33:33or or things, so you don't want to just
  955. 33:36always use one certain input or always
  956. 33:39not use it. Okay, so this is why you
  957. 33:41need to actually test things for
  958. 33:42yourself to see if it helps or it hurts.
  959. 33:46And that's it pretty much. So, we got
  960. 33:48the accuracy again, the MCC, and it's
  961. 33:51saying the model quality is well above
  962. 33:53the random chance on synthetic data. The
  963. 33:55triple barrier labeling and training
  964. 33:57pipeline are correct. So, again, I know
  965. 33:59everything is fine. And if you were to
  966. 34:01run a backtest with this, we would have
  967. 34:02executed a total number of 1,816
  968. 34:06trades, and the win rate would have been
  969. 34:0899.83%,
  970. 34:10which is absolutely insane. Of course,
  971. 34:12you're not going to see this in a
  972. 34:13real-world scenario. The net profit or
  973. 34:15P&L is 251%,
  974. 34:18and that's because I did not use a
  975. 34:19compound position sizing. If I did, this
  976. 34:22number would have been crazy high, and
  977. 34:24the Sharpe ratio is 10.80, which again
  978. 34:27is totally unrealistic. And that's it.
  979. 34:29Now, guys, we are not done here. You
  980. 34:32should definitely check out the other
  981. 34:34types of machine learning stuff that
  982. 34:36just supports now. So, this was the
  983. 34:38multi-class that I just showed you.
  984. 34:40We also have the binary, which can be
  985. 34:42very helpful. So, for example, if you
  986. 34:44want to know if the trade you're about
  987. 34:47to take is going to be profitable or
  988. 34:49not. And maybe based on that, you want
  989. 34:51to set your position sizing. Or maybe if
  990. 34:53it's it tells you it's not going to be
  991. 34:55profitable, you just want to drop that
  992. 34:57entire trade. And by doing so, you're
  993. 34:59going to increase the win rate of your
  994. 35:01strategy. So, this could be super
  995. 35:03helpful. Check out this page. We also
  996. 35:05have another one for regression. Now, if
  997. 35:08you guys want me to make videos about it
  998. 35:10and explain it, well, drop a comment and
  999. 35:12let me know. I might do it. But, we also
  1000. 35:14have another one called meta labeling,
  1001. 35:17which is for setting the position sizing
  1002. 35:20of the trade. And pretty much, that's
  1003. 35:22it. Again, I also explain the stationary
  1004. 35:24data and the importance of using it. And
  1005. 35:26I'm giving some examples. So, instead
  1006. 35:28of, you know, the price, you should be
  1007. 35:30using something like this. Instead of
  1008. 35:32the ATR, you should be using something
  1009. 35:33like this. So, this is also a really
  1010. 35:35helpful page. And this was my first
  1011. 35:38attempt at adding machine learning to
  1012. 35:41the framework. So, I cannot wait to hear
  1013. 35:43your feedback, especially if you guys
  1014. 35:44are an expert in machine learning. Let
  1015. 35:46me know what you think about the
  1016. 35:47implementation that I just did. And
  1017. 35:49whether or not you want it to be more
  1018. 35:50flexible or if there's something that we
  1019. 35:52are missing here. Or if there are more
  1020. 35:54ways that you want to use for testing
  1021. 35:56the model and performance of the
  1022. 35:58strategy, which is using the machine
  1023. 36:00learning. Now, my goal was to make it so
  1024. 36:02easy that you guys don't have to
  1025. 36:05actually read about this concept as much
  1026. 36:07as I did just in order to be able to,
  1027. 36:09you know, try a couple of things.
  1028. 36:10Because I found the implementation of
  1029. 36:12machine learning very much scary, no
  1030. 36:15matter where I read about it. And I
  1031. 36:17think this just made it so much easier,
  1032. 36:20at least for me. And I hope it does the
  1033. 36:22same thing for you. Then we're going to
  1034. 36:23have a giveaway. A random subscriber who
  1035. 36:26likes and comments is going to win 1
  1036. 36:28million Punk Token. Now, let's pick the
  1037. 36:30winner from the previous video.
  1038. 36:34And the winner is, "Would be cool to see
  1039. 36:36how things work out if you give each
  1040. 36:38model personality trait like
  1041. 36:39ex-legendary trait." Yeah, that sounds
  1042. 36:42really great. Okay, thank you so much
  1043. 36:43for your comment. Please do reach out to
  1044. 36:45me so I can send you your tokens. Thank
  1045. 36:46you so much for watching. I'll see you
  1046. 36:48in the next one.

About this transcript

This page contains the full transcript of AI Trading Using Machine Learning (Step-by-Step) by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 7,654 words across 1,046 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.