YouTube2Text

ChatGPT o1: Alligator Day Trading Strategy in Python Makes 1721% — Transcript

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

Full transcript

  1. 0:00hey guys so today I'm going to write the
  2. 0:02day Turing version of the allegator
  3. 0:04strategy using the chat gp01 model while
  4. 0:07I was writing this strategy I happened
  5. 0:09to learn about two new indicators that I
  6. 0:11didn't know about that improve the
  7. 0:12results of this strategy but not only
  8. 0:14that the result of this strategy
  9. 0:16happened to beat even my best private
  10. 0:18strategy yet which is why I was a bit
  11. 0:20hesitant to even release this video but
  12. 0:22I did it anyways so it's going to be
  13. 0:24awesome let's get right into
  14. 0:26it this is the prompt that I used please
  15. 0:29explain how the alligator strategy Works
  16. 0:31assume I want to write it with code so
  17. 0:33explain to me entry and exit rules for
  18. 0:35it also tell me which indicators would
  19. 0:37be nice to use alongside with it
  20. 0:39especially for avoiding ranging markets
  21. 0:41now first let me show you the alligator
  22. 0:43strategy in action it consists of three
  23. 0:45moving average lines the blue line as
  24. 0:47explained by Chad GPT is a smooth
  25. 0:50average with a period of 13 the red line
  26. 0:53is called the teeth of the alligator and
  27. 0:55it has a period of eight which is our
  28. 0:57fastest moving average is called the
  29. 0:59lips of the alligator and it has a
  30. 1:01period of five and the basic idea is
  31. 1:03that when the alligator is waking up for
  32. 1:05example in here it will start to open
  33. 1:08its mouth and when it is doing that
  34. 1:11first we're going to see the lips of the
  35. 1:12alligator and then its teeth and then
  36. 1:14its jaw and when these lines are
  37. 1:17crossing each other it means that the
  38. 1:18alligator is closing its mouth and the
  39. 1:21trend is over all right so what are the
  40. 1:22entry rules we want the value for the
  41. 1:24lips to be bigger than teeth and both of
  42. 1:27them to be more than the jaw the other
  43. 1:29thing is is that we want the current
  44. 1:30price to be above all the three lines
  45. 1:33and the opposite is true for a short
  46. 1:35position right so let's go to Jesse and
  47. 1:37start by creating a new strategy I'm
  48. 1:39going to call it
  49. 1:41alligator AI then I will open my pie
  50. 1:45charm editor and open the code here
  51. 1:47first let's define a new property and
  52. 1:49name it alligator and in it I'm simply
  53. 1:53going to return ta alligator and then
  54. 1:56passing the current candles and I'm not
  55. 1:58even going to change the parameters next
  56. 2:00I'm going to Define another property and
  57. 2:02I'm going to call it Trend and in it I'm
  58. 2:04going to say if the current alligators
  59. 2:06lips are bigger than the alligator's
  60. 2:10teeth and if this one is bigger than the
  61. 2:14alligator's jaw I'm going to return one
  62. 2:18actually we also supposed to check for
  63. 2:20the price so we want to also make sure
  64. 2:22that the current price is above the lips
  65. 2:26of the alligator if the opposite of this
  66. 2:28is true I'm going to return minus and if
  67. 2:30none of these are true I'm going to
  68. 2:32Simply return zero all right so my in
  69. 2:34rule is going to be whether or not the
  70. 2:36current Trend equals one for a short
  71. 2:38position I will do the opposite all
  72. 2:41right now that we have our entry rules
  73. 2:42it's time to set the position sizing all
  74. 2:44right so my entry price is going to be
  75. 2:47the current price because I want to open
  76. 2:49the position using a market order my
  77. 2:51stop is going to be the current entry
  78. 2:53minus the ATR with default values
  79. 2:57multiplied by two now using these two I
  80. 2:59want to risk only 3% of my capital in
  81. 3:01each trade so I'm going to say Quantity
  82. 3:05equals utils risk to quantity for the
  83. 3:09first one I'm going to pass my available
  84. 3:11margin next we have the risk which I
  85. 3:13wanted to be three next I will pass my
  86. 3:17entry and then the Stop and lastly I
  87. 3:22will say the furite is the current fee
  88. 3:24of the exchange that I'm trading this
  89. 3:26all right now we're ready to submit the
  90. 3:27order and I'm going to Simply say self
  91. 3:29bu equals
  92. 3:32quantity and then pass the price which
  93. 3:35is
  94. 3:36inry now for my short condition I will
  95. 3:39simply do the opposite of this so
  96. 3:41instead of subtracting the ATR by two
  97. 3:44I'm adding it all right now the value
  98. 3:46for shoot cancel entry it needs to be
  99. 3:48here but it doesn't matter what I said
  100. 3:50here because I'm using a market order to
  101. 3:52open my position so we're not going to
  102. 3:53have any cancellations whatsoever for my
  103. 3:56exit rule at first I tried what chat gbt
  104. 3:58suggested which is to close the position
  105. 4:00when the lips in other words the green
  106. 4:02line crosses back over the teeth in the
  107. 4:05opposite direction now let me show you
  108. 4:07how to write that first we can simply
  109. 4:09Define the update position method and in
  110. 4:11it I'm going to say if we are in a long
  111. 4:15position and the current trend is no
  112. 4:19longer one that means we have a trend
  113. 4:22reversal so simply liquidate my position
  114. 4:25and of course we would do the opposite
  115. 4:27for short positions all right so let's
  116. 4:29let's go and execute a back test for
  117. 4:33this first I will start with the 15
  118. 4:36minutes time frame and as for the
  119. 4:37duration of the back test I will start
  120. 4:39since the beginning of
  121. 4:412022 and I will back test it up until
  122. 4:44just a few days ago and the fast mode is
  123. 4:46on so it's a benchmark so let's run it
  124. 4:50while this is going I'm going to also
  125. 4:52back test it on a bigger time frame such
  126. 4:53as 30 minutes and another one with the
  127. 4:57hourly and then another one with the 4
  128. 5:03hours all right so this is the result
  129. 5:05for the 4 hours this is for 1 hour this
  130. 5:08is for 30 minutes and this is for 15
  131. 5:10minutes all right so the lower the time
  132. 5:12frame the more it actually loses so this
  133. 5:14means we need some filters so the first
  134. 5:16thing that I'm going to do is to use
  135. 5:18what attribut is suggested for avoiding
  136. 5:20the ranging Market the first is to use
  137. 5:23the adx indicator so let's go back and
  138. 5:25Define a new
  139. 5:27property going to call it adx
  140. 5:30and simply return whether or not the
  141. 5:32current
  142. 5:33adx for the current
  143. 5:36candles is more than 30 and in my inter
  144. 5:39rule I will say and self. adx I'll do
  145. 5:43the same for short positions so let's go
  146. 5:46back and execute everything one more
  147. 5:48time because I want to be able to
  148. 5:51compare the results very easily on The
  149. 5:52Benchmark page I'm going to remove some
  150. 5:54of these items such as the start date
  151. 5:57and the Finish date and the name of the
  152. 5:58strategy The Exchange symbol and the net
  153. 6:02profit and sortino and Omega ratios all
  154. 6:05right so we can see that all the results
  155. 6:08improved not only that the one with the
  156. 6:104 hours time frame is actually looking
  157. 6:12really good and these are the other ones
  158. 6:14by the way I tried almost everything
  159. 6:16that CHD suggested but in this video I'm
  160. 6:18only showing you the ones that actually
  161. 6:19worked for me so the next thing that I
  162. 6:21tried and it helped a lot was using a
  163. 6:24higher time frame so let's go back and
  164. 6:26Define a new property and I'm going to
  165. 6:28call this the the long-term candles and
  166. 6:31in it I will return the G candles first
  167. 6:34I will pass the current exchange then
  168. 6:37the current symbol and as the time frame
  169. 6:41I will pass 4 hours but since we are
  170. 6:43also trading the 4 hours time frame I
  171. 6:45need to write this in a dynamic way so
  172. 6:47that if we are trading it we we should
  173. 6:49use a bigger time frame so I'm going to
  174. 6:50change this code to say big TF equals 4
  175. 6:54hours but if the current time frame
  176. 6:57equals 4 hours then use the 6 hours and
  177. 7:01I will replace this with big TF all
  178. 7:04right next I'm going to copy what I
  179. 7:06wrote for the trend paste it here and
  180. 7:09I'm going to call this one big Trend now
  181. 7:12I'm not going to use this value of the
  182. 7:13alligator because it is using the
  183. 7:15current candles so I will also duplicate
  184. 7:19this one and call it Big and instead of
  185. 7:22using the current candles I will use the
  186. 7:24long-term Candles now in here instead of
  187. 7:28this one I will replace it by big
  188. 7:33alligator and in my entry rules I will
  189. 7:35add another condition saying if the
  190. 7:37current big Trend equals one and I'll do
  191. 7:40the opposite for my short positions so
  192. 7:42now let's go back to Jesse and rerun
  193. 7:44everything one more
  194. 7:46time so nearly all the results are
  195. 7:49improved except the one for the 4 hours
  196. 7:51but it's not looking bad it's just that
  197. 7:53the 1 hour and 30 minutes look much
  198. 7:56better now the 15 minutes is still very
  199. 7:59bad now because the 1 hour is looking
  200. 8:01good here I did what I usually do with
  201. 8:03lower time frames which is instead of
  202. 8:05taking the profit dynamically like we
  203. 8:07did in here I'm going to take profit at
  204. 8:09a specific Target so I'm going to remove
  205. 8:12this and instead I'm going to add a new
  206. 8:14function called unopen position and in
  207. 8:17it I'm going to say if the current
  208. 8:19position is a long position I want you
  209. 8:21to submit the subplus the quantity of it
  210. 8:24is going to be the quantity of current
  211. 8:26position and the price of it as we Des
  212. 8:29cribed here is going to be the current
  213. 8:33price minus 2 times of the current ATR
  214. 8:37and if it is a short position we will do
  215. 8:40the opposite but I wanted to take profit
  216. 8:42at a specific point so I will say take
  217. 8:45profit equals the same but I want my
  218. 8:48risk reward ratio to be one so I will
  219. 8:50multiply it by two and I will do the
  220. 8:53opposite for my short positions all
  221. 8:56right so let's go back to Jesse actually
  222. 8:58I'm going to remove the 15 minutes
  223. 9:00because it's not performing well and it
  224. 9:01actually takes a lot to execute all
  225. 9:04right so let's rerun all the other three
  226. 9:07so while this is going I wanted to
  227. 9:08quickly remind you guys that we have a
  228. 9:10Discord Community with more than 3,000
  229. 9:12cons such as you and I we hang out there
  230. 9:14share ideas and help each other out and
  231. 9:16I would love to see you guys there so
  232. 9:18check this out all the results are
  233. 9:20improved and in fact the hourly looks
  234. 9:22really well the sharp ratio is 1.1 the
  235. 9:25max thron is minus 20 and the net profit
  236. 9:28is 106% so let's take a look at the
  237. 9:30equity curve which looks really
  238. 9:33well and this is for 30 minutes and this
  239. 9:36one is for 4 hours all right so while we
  240. 9:38are using the bigger time frame there's
  241. 9:41also one more trick that I usually use
  242. 9:43that works really well and that's using
  243. 9:44the 100 moving average but with the
  244. 9:47bigger time frame so I'm going to Define
  245. 9:49another property and call it the
  246. 9:51long-term Ma and in it I will say E
  247. 9:56equals T EMA I will pass the long-term
  248. 10:00candles and for the period I will use
  249. 10:03100 and I will say if the current price
  250. 10:06is bigger than e return one otherwise
  251. 10:12return minus one and in my entry
  252. 10:15conditions I will also add this one
  253. 10:17let's go back and rerun all of them here
  254. 10:20if you notice a sharp ratio number here
  255. 10:22you'll notice that all of them are
  256. 10:23slightly improved comparing to what we
  257. 10:25had before so let's take a look at the
  258. 10:27equity curve and this is how it looks
  259. 10:31now I like this one specifically because
  260. 10:33it seems that it's been going up and up
  261. 10:35and up and during this ranging Market it
  262. 10:37didn't do well but the truth is that
  263. 10:39almost every other Trend following
  264. 10:41strategy was getting slaughtered during
  265. 10:42this time all right so at this point I
  266. 10:44wanted to improve the results even
  267. 10:46further and I needed more indicators so
  268. 10:48I went back to chat gbt and I simply
  269. 10:49said I tried the strategy and indicators
  270. 10:52that you mentioned but I'm not getting
  271. 10:54the best results the adx is really
  272. 10:56helpful but I need more like it to avoid
  273. 10:58ranging conditions and it gave me a
  274. 11:00bunch of other ideas and indicators and
  275. 11:02I tried nearly all of them but none of
  276. 11:04them was really helpful now I don't know
  277. 11:06if you guys know about this or not but
  278. 11:07in the past few weeks I've been working
  279. 11:09on a custom version of GPT for Jesse
  280. 11:12which has access to the documentation
  281. 11:14and a strategy examples that I've wrote
  282. 11:16myself it's using the open AI API so
  283. 11:18it's pretty much the same thing as chat
  284. 11:20GPT except it has a better knowledge
  285. 11:22about ALG trading now I simply pasted my
  286. 11:25strategy so far and I just said that you
  287. 11:28know what the ad was really good but I
  288. 11:30tried a bunch of others and give me some
  289. 11:33new ones and it started giving me ideas
  290. 11:35such as the obv and other volume
  291. 11:37indicators which almost never work out
  292. 11:39for me it also suggested the RSI which
  293. 11:41wasn't helpful macd again not helpful
  294. 11:44until I came across this one the CMO
  295. 11:47which is a momentum indicator that
  296. 11:48escalates betweenus 100 and plus 100 it
  297. 11:52also gave me the code so this is how to
  298. 11:53define it inside Jesse and this is how
  299. 11:56to use it so we can say if the value of
  300. 11:58CMO is bigger than 50 I want to take
  301. 12:00long trades and the opposite for short
  302. 12:02trades so first let me show you how it
  303. 12:04looks like we have this threshold which
  304. 12:06is set to zero if the price of the CMO
  305. 12:09is bigger than that it means we have an
  306. 12:11uptrend if it's below that it means we
  307. 12:14have a downtrend but what we really need
  308. 12:16is for the value of it to be above a
  309. 12:18certain threshold now the one that
  310. 12:20really worked well for me was
  311. 12:2230 and minus 30 for short trades so if
  312. 12:26this value is above 30 we want to look
  313. 12:28for long trades if it's below this like
  314. 12:31in here or here we want to look for
  315. 12:34short trades so let's go back and Define
  316. 12:36a new property and I'm going to call it
  317. 12:39CMO and I'm going to return ta CMO and
  318. 12:43that's it now in my inry condition I
  319. 12:45will say and the CMO value is bigger
  320. 12:49than 30 and I will do the opposite for
  321. 12:52my short positions so let's go back to
  322. 12:54Jesse now remember these numbers now
  323. 12:57let's reexecute them all right so it
  324. 13:00improved the results for the 4 hours but
  325. 13:02in hourly it actually didn't help I
  326. 13:04think it made it slightly worse and this
  327. 13:07is for 30 minutes so let's go back and
  328. 13:09try the same thing except with the
  329. 13:11number
  330. 13:1320 and reexecute everything all right
  331. 13:16check this out the sharp is now at 1.4
  332. 13:19for the hourly and the panl is at
  333. 13:25147% this looks
  334. 13:27fantastic and this is for 30 minutes and
  335. 13:30this is for 4 hours the 4 hours actually
  336. 13:32didn't get better but the hourly looks
  337. 13:35really good especially before 2024 all
  338. 13:38right next I came back to the GPT and I
  339. 13:41kept asking for other suggestions and I
  340. 13:42tried nearly all of them until I came
  341. 13:45across this one the stochastic
  342. 13:47oscillator now this is how we can Define
  343. 13:49it in Jesse and this is obviously how we
  344. 13:51can use it all right so let me show you
  345. 13:52how it looks
  346. 13:54like but in my experience the stochastic
  347. 13:57RSI works much better than the stasic so
  348. 14:00I will also add this one now I don't
  349. 14:02know why that is but again this one
  350. 14:04usually works better in my strategies
  351. 14:07which is why I actually went with this
  352. 14:08one in my strategy all right so we have
  353. 14:10two thresholds at 80 and 20 so basically
  354. 14:14it's very similar to how the RSI works
  355. 14:16when the value of it is below 20 it
  356. 14:18means that the market is oversold and
  357. 14:20when it is above 80 it means that it is
  358. 14:22overbought which is good for shorting so
  359. 14:25let's go back and Define a new property
  360. 14:27and I'm going to call it the
  361. 14:30srsi and in it I will return
  362. 14:33srsi I will pass the current candles and
  363. 14:36I will leave the default values next in
  364. 14:38my entry conditions I will say if the
  365. 14:41RSI is below 20 I will take long
  366. 14:44positions and if is above 80 I will take
  367. 14:47short positions so let's go
  368. 14:50back again take a look at
  369. 14:52this now let's reexecute all of them
  370. 14:56seems like we're getting an error oh so
  371. 14:58basically basically the stochastic RSI
  372. 15:01it doesn't return one scolar value it
  373. 15:04returns a name Tuple as you can see here
  374. 15:07so what I wanted to return is the value
  375. 15:10K now by the way K is this blue line and
  376. 15:14D is this orange line which is a moving
  377. 15:16average of that but we don't really care
  378. 15:18about that we just want the Blue Line
  379. 15:20itself all right so let's go back and
  380. 15:22reun them one more time wow it is much
  381. 15:25better look at this sharp on the 30
  382. 15:27minutes is 1.9 99 for hour Le 1.5 on the
  383. 15:314 hours it came down but at this point I
  384. 15:34don't think I'm going to trade this one
  385. 15:35at all so let's just close it this is on
  386. 15:39the 30 minutes and this is on the hourly
  387. 15:43now both of these look good but this one
  388. 15:45looks much better now here's the thing
  389. 15:47though the Maxon is only minus 6 which
  390. 15:50is basically nothing because I'm
  391. 15:52comfortable to take as much as- 30% Max
  392. 15:54draw down and for the hourly it is- 7%
  393. 15:57so that means I can simply go back and
  394. 16:00multiply the size of my positions by
  395. 16:03let's say five so let's rerun this one
  396. 16:06more time all right so now when the max
  397. 16:09Ron is minus 29% the net profit is at
  398. 16:141,721 per. so let's take a look this is
  399. 16:17how it looks like now you cannot even
  400. 16:20see the equity care of Bitcoin anymore
  401. 16:23let's take a look at the hourly now both
  402. 16:25of them look fantastic even during this
  403. 16:28this nasty Market range that we had
  404. 16:31again this is how the BTC was and this
  405. 16:34is how our Equity C looks like by the
  406. 16:37way I also extended the duration of the
  407. 16:39back test starting from 2022 for this
  408. 16:42strategy and here's the result and I
  409. 16:44also made a premium version of the same
  410. 16:45strategy and this is the result for that
  411. 16:48so let's compare the two so instead of
  412. 16:511300% profit now we're making 33% and
  413. 16:55the Max draw down is even lower the
  414. 16:57sharp ratio instead of 1.5 5 is now 2
  415. 17:00and the Calo ratio instead of 2.2 is now
  416. 17:023.8 the annual return instead of 74% is
  417. 17:06now
  418. 17:07107% and the win rate is 72% instead of
  419. 17:1162 and the average holding hours for
  420. 17:13both of them are around 9 hours which
  421. 17:15makes it a day trading strategy you can
  422. 17:18access the source code for both
  423. 17:19strategies on our website if you haven't
  424. 17:21checked out this page yet now is the
  425. 17:23time to do so there are tons of other
  426. 17:25strategies in here and you can very
  427. 17:27quickly see the results of each strategy
  428. 17:29on various periods and symbols and time
  429. 17:31frames as always we're going to have a
  430. 17:33giveaway a random person who likes this
  431. 17:35video posts a comment and subscribes to
  432. 17:37this channel is going to receive 1
  433. 17:39million bnk token all right let's pick
  434. 17:40the winner for the previous
  435. 17:43video and the winner is really nice
  436. 17:45features for back test thank you so much
  437. 17:47for your comment please reach out to me
  438. 17:49so that I can send you your bunk tokens
  439. 17:51thank you for watching and happy Trading
  440. 17:54[Music]
  441. 17:58oh

About this transcript

This page contains the full transcript of ChatGPT o1: Alligator Day Trading Strategy in Python Makes 1721% by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 3,381 words across 441 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.