YouTube2Text

GPT: Trading Strategy in Python makes 805% (+ Monte Carlo simulation results) — Transcript

by Algo-trading with Saleh · 4,775 words · 637 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Hey guys, it's so today I'm going to
  2. 0:01show you a swing trading strategy that
  3. 0:04not only produces good results in a back
  4. 0:06test, but it also has one of the best
  5. 0:08Monte Carlo simulations results that
  6. 0:10I've ever seen. As always, first I will
  7. 0:12show you the entry and exit rules of the
  8. 0:14strategy on Trading View. And then we
  9. 0:16will feed those rules into GPT to
  10. 0:19convert into Python code so we can run
  11. 0:21some actual back test on them. And
  12. 0:23before I continue, I got to say I am not
  13. 0:25a financial adviser. This is a tutorial
  14. 0:27and you should always do your own
  15. 0:29research before trading. So with that
  16. 0:30out of the way, let's get right into the
  17. 0:32video. Now firstly, we want to ensure
  18. 0:35this is a trending market. For that, the
  19. 0:37best indicator that I always use is the
  20. 0:39ADX. So let's add it to our chart.
  21. 0:42Now we need the threshold of this to be
  22. 0:4443. So let's add it here. So you see, I
  23. 0:48only want to take trades if the value of
  24. 0:50the ADX is above the threshold, like in
  25. 0:52here. Now, by the way, the time frame of
  26. 0:53the strategy is also the 4 hours. So,
  27. 0:56make sure you set your chart to this.
  28. 0:58Next, we want to make sure it is an
  29. 1:00uptrend or a downtrend and take a trade
  30. 1:02according to that. For that, we're going
  31. 1:04to simply use three moving average
  32. 1:06lines. So, let's look up EMA and add it
  33. 1:09three times to my chart. And then, we're
  34. 1:12going to change the periods. First,
  35. 1:14instead of nine, let's use 30. Next, I'm
  36. 1:18going to edit this to 46. And next I'm
  37. 1:23going to increase it to 80. Now also
  38. 1:27let's change the style of this to be
  39. 1:29more clear. So let's make this a little
  40. 1:31bit thicker. All right. So you see I
  41. 1:33want to take a trade when the order of
  42. 1:35lines is like this. I want the blue line
  43. 1:37which is the fastest email line to be
  44. 1:40above the one that is slow. And both of
  45. 1:42them must be above the slowest one which
  46. 1:44is also the thickest one here. Now again
  47. 1:46the periods of 30, 46 and 80. And we
  48. 1:50also want the ADX to be evolved with
  49. 1:51threshold. So this would have been a
  50. 1:53valid trade for example. So you could
  51. 1:55say this is a slow taking strategies
  52. 1:57kind of similar to the turtle strategy
  53. 2:00if you've heard about it. So we're not
  54. 2:02going to be early in the trend. But
  55. 2:04because this is a swing trading
  56. 2:05strategy, we don't really care about
  57. 2:07that because as long as we can catch a
  58. 2:09trend, that's good enough for us. So
  59. 2:11this would have also been a valid trade.
  60. 2:14So would have been this. So you see in
  61. 2:16this entire trend we would have taken
  62. 2:17two trades which is really good and
  63. 2:20that's it really that's all the interior
  64. 2:21rules that is to it and now let's talk
  65. 2:23about how to exit the trade. So first
  66. 2:25let's remove this. Now for that I'm
  67. 2:27going to use the ATR indicator which is
  68. 2:30one of my most favorites. So basically
  69. 2:32this will give us an average number of
  70. 2:35how much the price is changing on each
  71. 2:38candle. So for example, if we had opened
  72. 2:40the trade let's say here or here or
  73. 2:42whatever this value here which is by the
  74. 2:44way an absolute value. So in this point
  75. 2:47it would have been 939.1
  76. 2:50right? So let's zoom in a little bit. So
  77. 2:53we want to set the stop loss below let's
  78. 2:56say this value but not just by one let's
  79. 2:58say multiply it by a value such as I
  80. 3:00don't know like three or two. So that
  81. 3:02would have been for example in here and
  82. 3:04then take profit would have been let's
  83. 3:06say here right? So this is how we would
  84. 3:09have set it. So the ATR you want to
  85. 3:11multiply it by a certain number and then
  86. 3:14add or subtract it from our entry price.
  87. 3:16Now once you write the code it will
  88. 3:18become more clear for you if it's not
  89. 3:20already. Now because this strategy is
  90. 3:22not taking that many trades I want to
  91. 3:24actually risk a little bit more. So I'm
  92. 3:26okay with risking 5% for each trade and
  93. 3:29that is 5% of my capital. Right? So it
  94. 3:32doesn't matter how many percentage it is
  95. 3:34from our entry to our stop loss. Okay.
  96. 3:37So what we care about is 5% of our
  97. 3:39capital. And for example, if I were to
  98. 3:41open a long position here and I wanted
  99. 3:43to risk 5% of my capital because you see
  100. 3:46the distance between here until here is
  101. 3:49actually less than 5%. That means that
  102. 3:52we would have had to use leverage in
  103. 3:55order to accomplish that. So unlike what
  104. 3:56people think about leverage, which is
  105. 3:58you know you are always risking more and
  106. 4:00it's always risky and dangerous, that's
  107. 4:03not really the case. like sometimes it
  108. 4:04could actually be used in a limited way
  109. 4:08and that is really helpful. All right.
  110. 4:09So now that we have both the entry and
  111. 4:11exit rules of the strategy, we can feed
  112. 4:14those into GPT to give us some Python
  113. 4:17code so we can run some back test on it.
  114. 4:19Now to do that you have two options. The
  115. 4:20first one is to use the cloud version
  116. 4:21that I made myself. It is basically the
  117. 4:23same GPT with custom models such as
  118. 4:25cloth on it, GPD5 or whatever, but with
  119. 4:29some custom instructions that I fed it
  120. 4:31specifically for Algo trading in Python.
  121. 4:33Or if you want to self host this thing
  122. 4:34yourself to use your own API keys if you
  123. 4:37have some privacy concerns or whatever,
  124. 4:39you can check out my channel and watch
  125. 4:41this video where I show you how to do
  126. 4:43exactly that. So again, you don't have
  127. 4:46to use the cloud version that I'm going
  128. 4:47to do, but it's going to be easy for me.
  129. 4:50So that's the one that I'm going to
  130. 4:51stick with. Now, as for the model, I
  131. 4:53have picked GPT5 mini, which is also the
  132. 4:55cheapest one, and you can get started
  133. 4:57with it absolutely for free. So, that's
  134. 4:59the one I'm going to use. Let's paste in
  135. 5:02the prompt. All right. So, write a trend
  136. 5:03strategy with these rules. Go long when
  137. 5:06you have an uptrend and the ADX is above
  138. 5:0843. For the trend, use three EMAs. A 30
  139. 5:11period EMA is 46 period and 80. The
  140. 5:15trend is up when the 30 EMA is above the
  141. 5:1746, which is above 80. And the current
  142. 5:20price is above all of them. Enter at
  143. 5:22price market risk 5% of account per
  144. 5:24trade. Set the stop loss at the
  145. 5:26enterprise minus 1.8 times the ATR value
  146. 5:29for take profit. Use the enterprise plus
  147. 5:313.3 times the ATR value. So you see when
  148. 5:34I win, I'm going to win bigger than when
  149. 5:36I loot. So even if the win rate of the
  150. 5:39strategy is going to be like 40% or 45%,
  151. 5:42I'm still going to sit at a win. So I
  152. 5:45don't need to win all the time. So,
  153. 5:46that's one of the good things about a
  154. 5:48strategy where your wins are going to be
  155. 5:51bigger than your losses. And for short
  156. 5:53positions, do the opposite. That's it.
  157. 5:55Very simple. Let's hit enter. All right.
  158. 5:57So, it gave us the code. Let's copy the
  159. 5:59name of it. Triple EMA trend and go to
  160. 6:03Jess's dashboard and generate a new
  161. 6:05strategy. And I'm going to paste the
  162. 6:07name here. Now, here's the code. Now,
  163. 6:10you could edit the code right from
  164. 6:11within the editor of Jess's dashboard.
  165. 6:14But what would have been better is if I
  166. 6:16open it inside a better editor such as
  167. 6:19cursor or VS code which is completely
  168. 6:21free and open source. So let's open it
  169. 6:23there. And now we can read the code. All
  170. 6:26right. So you see this is the base
  171. 6:29strategy code that Jesse generated for
  172. 6:31us. So let's go back to Jess GPT and
  173. 6:34copy this whole thing and paste it here.
  174. 6:38Now let's give it a read. So it defined
  175. 6:40a new property for EMA30 and in it it is
  176. 6:43simply returning TA. EMA which is the
  177. 6:45correct syntax within Jesse framework
  178. 6:47for defining an indicator. It is passing
  179. 6:50the current candles by saying
  180. 6:51self.candles and the period of it is 30.
  181. 6:54Define another one for EMA 46 EMA 80 and
  182. 6:59then it defined the ATR simply saying
  183. 7:01TATR and then passing the current
  184. 7:03candle. So you see it is very easy to
  185. 7:05define indicators inside Jesse and then
  186. 7:08it defined a new property for the ADX
  187. 7:10and next we get to the entry rules of
  188. 7:13the strategy using the should long
  189. 7:14method which is basically asking should
  190. 7:16we go long right now. So in it we just
  191. 7:19define some inter rules. So it's saying
  192. 7:21if the EMA 30 is above 46 EMA 46 is
  193. 7:24above 80 the price is bigger than all of
  194. 7:26them. So I find this to be a little bit
  195. 7:29hideous and unnecessary, but I'm going
  196. 7:32to leave it as it is because it works
  197. 7:34and you know unless if the model makes a
  198. 7:36mistake, we don't really need to change
  199. 7:38it. And if the current ADX is also above
  200. 7:4143. So this is perfectly correct. And
  201. 7:44then for the shoot short, which is for
  202. 7:45taking the short positions, it's doing
  203. 7:48the exact opposite. So this is also
  204. 7:50correct except remember that the ADX
  205. 7:52must still be above 43. So this is
  206. 7:55perfectly correct. And then for the go
  207. 7:58long method which is where we define the
  208. 8:00position sizing right. So assuming that
  209. 8:03the inter rules are correct and now we
  210. 8:05want to go long what should be our
  211. 8:07position sizing what should be the entry
  212. 8:09price or the stop-loss price or things
  213. 8:11like that. So we're going to say the
  214. 8:14entry is the current price which is a
  215. 8:17market order in other words and Jesse is
  216. 8:19smart enough to detect this behind the
  217. 8:22scenes. All right. And then for this
  218. 8:23stop loss, we're seeing the entry minus
  219. 8:25the current ATR multiplied by 1.8. And
  220. 8:28then the quantity, we want to risk 5%.
  221. 8:30Right? Now, to do this, we're going to
  222. 8:32use the risk to quantity utility
  223. 8:34function of Jesse. And what it needs
  224. 8:36from us to calculate things is our
  225. 8:38current capital or available margin. So
  226. 8:41we pass self available margin and then
  227. 8:43the number five for the number of how
  228. 8:47much we want to risk the percentage and
  229. 8:49then the entry which we defined here the
  230. 8:52current price and then the stop which we
  231. 8:54defined here and then we also need to
  232. 8:56set the fees. It's not necessary but
  233. 8:58it's better to do it. And for that we're
  234. 9:01saying fee rate equals self.fe rate
  235. 9:03which is the fees we're going to pay in
  236. 9:05the current exchange. And then to submit
  237. 9:07the actual buy order, all we need to do
  238. 9:09is to say self.by equals quantity and
  239. 9:12then the entry. That's it. Very very
  240. 9:15simple. Now for a short position, we're
  241. 9:16doing the exact opposite. So basically
  242. 9:18for the subus, instead of subtracting
  243. 9:20the ATR, we are adding it. And also
  244. 9:22instead of self buy, we are using
  245. 9:25self.ell to submit a sell order for a
  246. 9:28short position, which of course makes
  247. 9:29sense. Now assuming that everything went
  248. 9:31fine and we are now sitting on a
  249. 9:33position now is the time to submit both
  250. 9:35the takerit and the stop loss. So we're
  251. 9:38saying if it's a long position and that
  252. 9:40is very simple in JC simply say if self
  253. 9:43is long then we want to calculate the
  254. 9:45stops and take profit prices. Now we
  255. 9:47didn't have to do it like this. We could
  256. 9:48have simply write it here but this model
  257. 9:50chose this and we're going to go with
  258. 9:52that. So the stop loss equals the
  259. 9:54current positions entry price which is
  260. 9:56the current price also minus the current
  261. 9:58ATR minus 1.8. Now by the way the
  262. 10:01current ATR is what we defined here. All
  263. 10:03right. Now the take profit is going to
  264. 10:06be similar except we are adding it by
  265. 10:093.3 times of the ATR. And now is the
  266. 10:12time to actually submit the orders. Now
  267. 10:14this is the syntax in Jesse. So for a
  268. 10:16stop loss we say self to the stop loss
  269. 10:17and then we pass the quantity which we
  270. 10:19are passing the quantity of the current
  271. 10:21position and then the stop loss. Now for
  272. 10:22take profit still we're doing the same
  273. 10:25thing but except instead of saying self
  274. 10:27stop loss we say self dot takeprofit and
  275. 10:30if it's a short position again very easy
  276. 10:32in Jesse simply say is short we do the
  277. 10:36opposite right so instead of subtracting
  278. 10:38and adding we are adding and subtracting
  279. 10:40that's it now it is also doing something
  280. 10:42extra that I didn't ask so it's saying
  281. 10:44it's using the update position method of
  282. 10:45Jesse which we use when let's say for
  283. 10:49some conditions we want to liquidate the
  284. 10:51current position we don't want to wait
  285. 10:53until the stop loss or the take profit
  286. 10:55price is hit but that is not what I
  287. 10:57wanted to do in this strategy so this is
  288. 10:59extra and I'm going to remove it is also
  289. 11:01defined the should cancel entry method
  290. 11:03and it's returning true this method is
  291. 11:06used when we are using a limit or a
  292. 11:08stop-loss order in Jesse which is really
  293. 11:10necessary right because let's say you
  294. 11:12submit your limit order but the next
  295. 11:14candle closes and still your price
  296. 11:16hasn't been hit so now you ask yourself
  297. 11:18should I update the previous order or
  298. 11:20should I just leave it as it is but
  299. 11:21Because in this strategy we are using a
  300. 11:23market order. We don't need this and I
  301. 11:26can just remove it. All right. So now
  302. 11:28that we have everything we are ready to
  303. 11:30run some back test. Now by the way the
  304. 11:32LLM model added an extra py here. So
  305. 11:35make sure to remove that if it happened
  306. 11:37for you because that will cause an
  307. 11:39error. So let's go to JC go to the back
  308. 11:41testing page. Change the symbol into BTC
  309. 11:43USDT. the time frame into four hours and
  310. 11:47the strategy name must be triple EMA
  311. 11:51trend. And for the duration, let's begin
  312. 11:54since 2021 up until 2022
  313. 11:58and the first month.
  314. 12:01Make sure the fast mode is on and so is
  315. 12:02the benchmark. All right, so let's run
  316. 12:04this. And while that is going, I'm going
  317. 12:05to open another tab and it starts since
  318. 12:082022 up until 2023.
  319. 12:12Run it. And then another one with 2023
  320. 12:16up until 2024.
  321. 12:19And then 2024 up until 2025.
  322. 12:24And lastly,
  323. 12:26starting 2025
  324. 12:28until this month, which is September. So
  325. 12:31let's run it and let's take a look. So
  326. 12:34in 2021, this is how our equity curve
  327. 12:37looked like, right? So we took 14
  328. 12:39trades. We ended with 78% profit. The
  329. 12:43max was -3%.
  330. 12:46The win rate was 71%. So that is really
  331. 12:48great for a strategy where the average
  332. 12:52win to loss ratio is 1.44. So this is
  333. 12:55really great. The average holding time
  334. 12:57is 265 hours. So that is definitely
  335. 13:00long. Now if you are a swing trader,
  336. 13:03this might be fine for you. But if you
  337. 13:04are a scalper, you're going to have a
  338. 13:06hard time holding a position for that
  339. 13:09long. So just consider this and the
  340. 13:12sharp is close to two. So I love this
  341. 13:14results at least for this year. The
  342. 13:16calmer ratio is also 5.63.
  343. 13:20That is really good.
  344. 13:22All right. So let's go to the next year
  345. 13:25for 2022 which was a bare market. And
  346. 13:28here's our results. So we ended with 67%
  347. 13:32and a max of minus3. And this is for
  348. 13:362023.
  349. 13:38This is this is for 2024 and this is for
  350. 13:412025. Now if I go to the benchmarking
  351. 13:43page of Jesse, we can see all the
  352. 13:45results next to each other which makes
  353. 13:47it really easy for us to compare the
  354. 13:50results. So here is the maxon. You see
  355. 13:52all the numbers here and then we can see
  356. 13:55the sharp and compare all of them
  357. 13:56together. Now by the way the maxon of
  358. 13:59the strategy is a bit lower than my risk
  359. 14:01tolerance. So we could even go and
  360. 14:04increase the quantity. So let's go to
  361. 14:06the go along method for example and we
  362. 14:09can multiply this quantity number by a
  363. 14:11certain num multiplier such as two or
  364. 14:141.5 or whatever you're comfortable with.
  365. 14:17So, in case you were wondering why
  366. 14:20aren't we beating the market? Actually,
  367. 14:21we are beating the market here a little
  368. 14:24bit and also here. But in here, we're
  369. 14:26not beating the ending P&L number that
  370. 14:29the market made for us, right? Like if
  371. 14:31we just held BTC, we would have made
  372. 14:33more. But with the strategy, we didn't
  373. 14:36make as much. But because the max number
  374. 14:38is actually really low, if we had
  375. 14:41multiplied the quantity or the size of
  376. 14:43our position by three, we would have
  377. 14:45definitely beaten the market, right? So
  378. 14:47in case you are wondering for that,
  379. 14:49well, this is the solution to that. But
  380. 14:51when you do that, you also increase your
  381. 14:53risk. So that means if the strategy
  382. 14:55wasn't doing fine, you would have lost
  383. 14:57more. So you need to be very careful
  384. 14:59with that. But anyway, so let's go back
  385. 15:00to the benchmarking page and we can see
  386. 15:04the start and ending dates to know which
  387. 15:07result this is. We can very quickly
  388. 15:10rerun one of the results if that's what
  389. 15:11you wanted to do. We can also rerun the
  390. 15:13entire back test if that's what you
  391. 15:16needed. Let's say I change a certain
  392. 15:19part of the code. So let's multiply this
  393. 15:21by 1.5 for example
  394. 15:24and also for the shorting part. And
  395. 15:27let's say I wanted to see how the
  396. 15:29results look now, right? So we just
  397. 15:31click on this. And now if I go to the
  398. 15:34result, this is how it looks like.
  399. 15:38So you see now we are almost beating the
  400. 15:40market. Now if I had multiplied by two,
  401. 15:43we would have definitely done that. And
  402. 15:45here we're also making more. And also in
  403. 15:48here. Now let's also run another back
  404. 15:50test. It's starting 2021 up until ending
  405. 15:54date.
  406. 15:55Actually, I think I have a little bit
  407. 15:58more data because we're not in the
  408. 16:00beginning of September anymore. So,
  409. 16:02let's run it like this. And by the way,
  410. 16:04if you didn't have data like me,
  411. 16:06actually in this case, you can just go
  412. 16:08to the import page and choose BTC.
  413. 16:14So, let's do that and change this into
  414. 16:18Binance Pial futures. Click on import
  415. 16:22and you can easily do that. And you see
  416. 16:24it will skip the candles that already
  417. 16:26exist and it will only try to fetch the
  418. 16:28new ones. So let's give it a moment to
  419. 16:31finish this. I want to quickly remind
  420. 16:33you guys about Apex which is my favorite
  421. 16:35deck allowing you to trade perpetuals
  422. 16:37without providing any KYC while keeping
  423. 16:39the custody of your funds. If you sign
  424. 16:41up via my link, you will get 25% trading
  425. 16:44fee discounts. And you will also be
  426. 16:45supporting my work. Now that we have the
  427. 16:47candles, if I go back to the back
  428. 16:49testing page and rerun this, hopefully
  429. 16:52it should go just fine this time. All
  430. 16:55right, so this is the result of the
  431. 16:58equity curve. If we started trading this
  432. 17:00since the beginning of 2021 up until
  433. 17:04just a few days ago, this would have
  434. 17:06been how much we made. So 1,425%
  435. 17:10in profit with a max of minus 27%. So
  436. 17:13this is really great. The win rate is
  437. 17:1654%. For a strategy with a profit factor
  438. 17:19of 1.4, this is really good. And then
  439. 17:22the average holding time is 118 hours.
  440. 17:25Again, be careful with this. You're
  441. 17:26going to need to be patient with it. And
  442. 17:29the sharp is 1.61, which is really
  443. 17:32amazing. All right, so the results are
  444. 17:34really good, but the main reason I
  445. 17:37wanted to show you this strategy is the
  446. 17:39result of its Monte Carlo simulation.
  447. 17:41Now, if you have been following me, you
  448. 17:43know that recently I released a tool to
  449. 17:46run Monteol simulations with Jesse,
  450. 17:48which is really helpful. So, let's run
  451. 17:50that. Let's go and copy the name of the
  452. 17:53strategy and then go to that script that
  453. 17:56I gave you guys. Again, watch the video
  454. 17:58if you haven't or check out our
  455. 18:00documentation. And then I'm going to
  456. 18:01paste the name of it here. So, the name
  457. 18:03of the strategy, the time frame is 4
  458. 18:06hours. The symbol is BTC and the
  459. 18:08exchange is binance per features and we
  460. 18:11don't have any data out so I don't need
  461. 18:13to enable this part. And for the number
  462. 18:15of simulations I have picked 200 and as
  463. 18:18for the beginning of it let's set it to
  464. 18:22turn 21
  465. 18:24up until
  466. 18:26so basically the same thing that we did
  467. 18:28for our back test and the trading fees
  468. 18:33and everything else is just fine. All
  469. 18:35right. So, let's go to the terminal and
  470. 18:36I will simply say Python test Monte
  471. 18:39Carlo, which is the name that I gave
  472. 18:41that the script for you. It could be
  473. 18:42anything. Let's run it. Now, this is
  474. 18:45going to have to run 200 back tests very
  475. 18:49fast, right? But I'm also using 12 CPU
  476. 18:52cores, so it should take approximately a
  477. 18:55few minutes. All right. So, by the way,
  478. 18:57I'm getting an interesting error. The
  479. 19:00multiprocessing that I'm using is
  480. 19:02actually running out of space because I
  481. 19:04don't have enough empty space on my SSD
  482. 19:08or in my RAM. So, let's stop this cuz
  483. 19:11this isn't going as fast as I need it to
  484. 19:13be. So, we have multiple options. We can
  485. 19:17lower the amount of candles that we're
  486. 19:19going to use, right? So, let's bring
  487. 19:22this down to 2022 2023 actually because
  488. 19:27I wanted to include one bull market and
  489. 19:30one bare market. And yeah, so this
  490. 19:33should be fine. Let's give it another
  491. 19:36try.
  492. 19:37By the way, you might also get some
  493. 19:39other errors like this. And that is fine
  494. 19:41because you see since in this simulation
  495. 19:45we are generating simulated data.
  496. 19:48Sometimes that data doesn't play nice.
  497. 19:51So for example, the prices could be
  498. 19:52really low or things like that and that
  499. 19:55makes sense, but we don't need all the
  500. 19:57back tests to actually go through for us
  501. 20:00to have a result that we can read,
  502. 20:02right? So let's just wait and see how
  503. 20:04this turns out. All right, so the result
  504. 20:07is two tables and two chart pictures
  505. 20:10that we're going to take a look at. Now
  506. 20:12let's begin with this one, which gives
  507. 20:14us the Monte Carlo of the trade. So what
  508. 20:17if we took the same number of trades but
  509. 20:19the order of them were different? So
  510. 20:21instead of like winning, winning and
  511. 20:22losing, what what if it was losing and
  512. 20:25then winning and winning, right? So how
  513. 20:26would have our equity curve changed
  514. 20:28then? So let's take a look at the chart.
  515. 20:31So you see this is how actually in many
  516. 20:34of the simulations we would have done
  517. 20:35better. But in some of them, but very
  518. 20:39few actually things would have been
  519. 20:40worse, right? But also notice that the
  520. 20:44ending number for all of the equity
  521. 20:46curves, the original and the simulations
  522. 20:48are the same because these are the same
  523. 20:51trades. We're just changing the order
  524. 20:52which will change the draw down which
  525. 20:54will also change some of other metrics
  526. 20:56such as the sharp ratio which is
  527. 20:57basically how much you're making
  528. 20:58compared to how much risk you're taking.
  529. 21:00So if I take a look at this, you see the
  530. 21:02max draw down of the original was minus
  531. 21:0420% for that period. But the median had
  532. 21:07a max draw down of 32%. The best 5% had
  533. 21:10a draw down of 17% and the worst had 84.
  534. 21:14Now you should never really read the
  535. 21:16worst because it's always like this. So
  536. 21:19I don't really think this strategy is
  537. 21:21going to take this draw down. And you
  538. 21:23see also the sharp is changing. Now
  539. 21:25let's take a look at this part which is
  540. 21:27the monte color for the candle. So
  541. 21:29basically not only we run the same back
  542. 21:31test on the original data, we also
  543. 21:33generate some new data based on the
  544. 21:35original candles. Now, this is a very
  545. 21:38complex but interesting topic. The
  546. 21:40method I'm using here is called moving
  547. 21:42block bootstrapping. So, we're basically
  548. 21:45using the real data. We're just changing
  549. 21:47the order of them. And you could also
  550. 21:49assume that this is a way to stress test
  551. 21:52the result of your strategy, right? So,
  552. 21:54let's take a look at this. So, this
  553. 21:57would have been the original back test
  554. 21:59and these would have been the
  555. 22:00simulations. So the ending number isn't
  556. 22:02really great, but if you take a look at
  557. 22:04here, many of the simulations were
  558. 22:06actually doing better. So it's
  559. 22:08definitely good enough. Now let's read
  560. 22:10the table and you see the max draw down
  561. 22:13was - 20% for the original. We already
  562. 22:15showed that earlier. The median had a
  563. 22:18max draw down of minus 28%. So this is
  564. 22:21what I really like because my risk
  565. 22:23tolerance allows me to take as much as
  566. 22:25minus 30% draw down. And if the median
  567. 22:29of the simulations is only minus 28%
  568. 22:33that means it's good enough. So even if
  569. 22:36I wasn't as lucky as the original back
  570. 22:38test the maxon would have still been
  571. 22:40acceptable for me. And in the best 5% it
  572. 22:42was actually minus 70%. So it was even
  573. 22:45better. And what I want to see is if the
  574. 22:47original back testing was worse than the
  575. 22:49best 5%. So I don't want it to be inside
  576. 22:52the best 5%. All right. Now for the
  577. 22:55sharp for the original it was 1.988
  578. 22:58but for the median it was 1.13 and you
  579. 23:01see the original is actually lower than
  580. 23:03the best 5%. Another way to read this is
  581. 23:06to forget about the original just read
  582. 23:08what you see for the median which is
  583. 23:101.13
  584. 23:11and the question is is that good enough
  585. 23:14for me to trade it? So what if I wasn't
  586. 23:16lucky forget the best 5% forget the
  587. 23:18original what if the median was
  588. 23:20happening? Not only that, even the worst
  589. 23:225% has a sharp of 0.04,
  590. 23:26which isn't great, but it's not
  591. 23:28negative. So, you see, even in the worst
  592. 23:305%, I wasn't ending with losing money.
  593. 23:33So, that means if I run this strategy
  594. 23:35long enough, it will hopefully generate
  595. 23:39me profit. Now, we never have 100% thing
  596. 23:43in trading. So, don't think that if
  597. 23:45you're going to run the strategy, you
  598. 23:46will definitely make money. There's no
  599. 23:48printing machine. There's no guarantee
  600. 23:50in trading, but I like the odds that I'm
  601. 23:52seeing here. And you can also read the
  602. 23:53other metrics if you like to. But
  603. 23:56overall, I'm happy with these results.
  604. 23:58Now, something interesting that you
  605. 23:59should know is that I actually released
  606. 24:01this strategy more than a year ago on my
  607. 24:04channel and on our website. But this is
  608. 24:07the premium version of it. It was called
  609. 24:10Trend Swing Trader V2. So if you want to
  610. 24:13see the result of it for other periods
  611. 24:16or time frames or symbols, you can do
  612. 24:18so. But one interesting fact is that
  613. 24:20back then when I release this, let's say
  614. 24:22you were wondering, does the result of
  615. 24:24it also work for fusion data? Well, now
  616. 24:27we have the result. If you were a
  617. 24:30premium user, you would have had access
  618. 24:32to the exact same thing that I just ran.
  619. 24:34And you would have seen that let's say
  620. 24:36in 2025
  621. 24:38the strategy well here it wasn't making
  622. 24:41much but actually I don't have the
  623. 24:43result of more of them. All right we do
  624. 24:45have it here. Let me open it. All right.
  625. 24:47So since the beginning of 2025 up until
  626. 24:50September still it was making money and
  627. 24:54it was also doing the same thing in
  628. 24:552024. So you see if you wanted to do
  629. 24:58some forward testing here it is. If you
  630. 25:01enjoyed the video, please consider
  631. 25:02giving a like and subscribe to the
  632. 25:04channel for more videos and strategies
  633. 25:06like this one. Thank you so much for
  634. 25:08watching. I'll see you in the next one.
  635. 25:10[Music]
  636. 25:13[Applause]
  637. 25:14[Music]

About this transcript

This page contains the full transcript of GPT: Trading Strategy in Python makes 805% (+ Monte Carlo simulation results) by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 4,775 words across 637 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.