Claude 4 tested: Good for algo-trading strategies? — Transcript
Full transcript
- 0:00Hey guys, this is S. The Anthropic team
- 0:01just released Cloud 4. Now, we already
- 0:04know that so far Claude Sonnet 3.7 was
- 0:07the top coding model, but what we care
- 0:09about as algo traders is the performance
- 0:11of the model for algo trading. That
- 0:13means things such as writing strategies,
- 0:15improving the existing ones, coming up
- 0:17with trading ideas, converting pin
- 0:19script strategies into Python, all the
- 0:21good stuff like that. So, in this video,
- 0:23I'm going to review the model and test
- 0:25it with actual use cases so we can see
- 0:27how good it is. So if you guys are as
- 0:29excited as I am, let's get right into
- 0:31it. In order to get the model to perform
- 0:33best for algo trading, we're not going
- 0:35to use the cloud platform itself. We
- 0:37need a platform which allows us to add
- 0:39our own custom instructions. I already
- 0:41open sourced the instructions that I
- 0:43made for Jess GPT which is built for
- 0:44algo trading and you can find the
- 0:46repository here. If you don't know what
- 0:48instructions are and how you can do
- 0:50that, you can watch my previous video
- 0:51here where I explain how to self-host
- 0:54this thing by yourself. But I'm not
- 0:56going to do that. Instead, I will use
- 0:58Jesse GPT, which is basically the cloud
- 1:00version of this, and it's just ready out
- 1:02of the box. You can get started for free
- 1:04or even upgrade to premium. But if you
- 1:07don't want to pay for it, or if you have
- 1:08privacy concerns, then just self-hosted
- 1:11with that video. So, let's get started
- 1:12with the first question. So, let's paste
- 1:14it here. Write a golden cross strategy
- 1:16that uses the 50 and 100 moving
- 1:19averages. Close the position when the
- 1:20entry rule is no longer valid. So, this
- 1:23is basically like the hello world of
- 1:24algo trading. So let's press
- 1:27enter. And it defined two moving
- 1:30averages. The shoe long says the moving
- 1:32average of 50 should be above 100. It's
- 1:36not shorting which we didn't ask for.
- 1:38And it's using half the capital for
- 1:39opening the position. And it is closing
- 1:42it when the entry rule is the opposite.
- 1:44So this is actually perfect. And by the
- 1:46way, make sure you are using close for
- 1:48by clicking here and choosing this.
- 1:50Anyways, let's copy this. go to Jesse
- 1:52and create a new strategy which you can
- 1:54do by clicking here or here. Now I'm
- 1:57going to name it cloud for
- 2:00test. I could just paste it here or I
- 2:04could open my VS code editor and look it
- 2:06up
- 2:07here. So let's paste it here. All right.
- 2:10So let's go to the back testing page and
- 2:12look up cloud for test. The 4our time
- 2:15frame is fine. The BTC USDT is also
- 2:18fine. And we have one month of back
- 2:21test. The fast mode. Let's enable it.
- 2:25Right. So, this is good. Let's start
- 2:27it. It went just fine. It took two
- 2:30trades, made 5%. So, this is perfect.
- 2:32And if I go to the view charts, we can
- 2:34also look at the trades that it took.
- 2:36So, it opened the long position. It
- 2:37closed it here, opened and closed here.
- 2:40So, this looks perfect. So, we're going
- 2:42to give it a pass. Next, we're going to
- 2:44ask it to convert this pin script
- 2:45strategy into Python code. Now to find a
- 2:48strategy on trading view, I'm going to
- 2:49look up super trend strategy. Now I
- 2:53already have added it to my chart. So
- 2:56let's see how it looks
- 2:58like. All right. So it opens a position
- 3:01and closes it here. These are the
- 3:03results. And to look at the source code,
- 3:05let's click here, copy the whole thing,
- 3:09go back
- 3:10here, and do this.
- 3:17All right. So, it defined a super trend
- 3:19like this, which seems fine. The trend
- 3:23is either one if the price is bigger
- 3:25than the super trends trend line. That's
- 3:27perfectly correct. It's also checking
- 3:30the previous trend. That seems fine. So,
- 3:32it says open a long position if the
- 3:34current trend is one and the previous
- 3:36trend was minus one. So, it's trying to
- 3:39catch it the moment that the crossover
- 3:40happens. We don't really need to do
- 3:42this, but if you do, you're not going to
- 3:44open a long position while the trend has
- 3:47been in uptrend for a while. So, it's
- 3:49good practice, but I don't usually do it
- 3:51myself. All right, so this seems fine.
- 3:53Let's copy the whole thing. Go back and
- 3:55paste it. Go to Jesse and rerun it, but
- 4:00this time with the new
- 4:01code. All right, so it took 17 trades,
- 4:05but the time frame is hourly now. And
- 4:08let's also take a look at the trades it
- 4:10took. All right. So this is perfect
- 4:12actually. So we bought here for a long
- 4:15position and
- 4:18we sold it here. So sell long. So this
- 4:22seems perfect. And yes, here the trend
- 4:24is changing. So yeah, this is really
- 4:27really perfect. Now it's not using two
- 4:29colors for the super trend like we do on
- 4:32Trading View. I could have done that,
- 4:33but we could just ask it because we
- 4:36didn't. So this is also definitely a
- 4:38pass. All right. Next, develop a mean
- 4:40reversion strategy using the Ballinger
- 4:42bands and the RSI with the seven
- 4:45period. So here's a mean version
- 4:48strategy. It defined the Ballinger bands
- 4:50with a period of 20 and multiplier of
- 4:53two. The RSI 7. It's like this. All
- 4:55right. So we lost the formatting and
- 4:58that's because it added an extra py
- 5:00here. So let's copy the whole thing. Go
- 5:02to the editor. Paste it here. But
- 5:05remember to remove this. All right. So
- 5:07let's take a quick look at the code. So
- 5:09yes, the period is now 74 RSI. That's
- 5:12correct. The entry rule is when the
- 5:15price is below the lower band and the
- 5:18RSI is below 30, which means it is
- 5:20oversold. So we want to buy. So that's
- 5:22perfectly correct for position
- 5:25sizing. This also looks perfect. We have
- 5:27a stop loss with the ATR multiplied by
- 5:311.5. Submitted the buy order. So it also
- 5:36submitted the stop loss and take profit
- 5:37at the moment the position is opened. So
- 5:40this looks perfect. All right. So here's
- 5:42the thing though. Even though it
- 5:43submitted the takerit and its price is
- 5:46the middle band of the Ballinger bands,
- 5:48it is also saying that if that is the
- 5:51case, we want to liquidate the current
- 5:53position when a closing candle occurs.
- 5:56But we don't really need this because if
- 5:58we have the takerit already submitted at
- 6:00this price, then this condition will
- 6:03never be needed to be executed. But I'm
- 6:05just going to leave it be because it
- 6:07should execute just fine. So let's rerun
- 6:11it. All right. So we have an
- 6:13error because this syntax is not
- 6:17correct. So if I remove this, it should
- 6:22work. And it does. Well, it does work,
- 6:25guys, but it just got it wrong because
- 6:28of that parameter. So, I'm going to give
- 6:29it a
- 6:31fail. Now, it's not a big fail, of
- 6:33course, because it was just one tiny
- 6:35mistake, but I guess that's the rules
- 6:38for this video. Next, we're going to ask
- 6:40it to write a strategy that uses the
- 6:41Fibonacci retracement levels for entry
- 6:44and exit points. So, this is a tough
- 6:46one. Let's hit enter. Here's a Fibonacci
- 6:49retracement strategy that identifies
- 6:51swing highs and lows and uses Fibonacci
- 6:54levels for entries and exits. So it
- 6:57defined some default variables. It's
- 7:00using the ATR and
- 7:03ADX. I defined the swing
- 7:05points. We have a look back
- 7:08period which we define here. It is 20.
- 7:11So that's correct because for Fibonacci
- 7:13we always need a look back
- 7:16period. For the highs, it's getting the
- 7:18last 50 candles and their high prices.
- 7:22And this is exactly correct. We also do
- 7:25the same for
- 7:28lows. All right. And then we have the
- 7:30fib levels which it defined as a
- 7:33dictionary like this. It multiplied it
- 7:36by Fibonacci numbers. So this looks
- 7:40good. So let's copy the whole thing. Go
- 7:43back to the editor. Paste it here. go to
- 7:46Jesse and run
- 7:48it. It ran. Let's also take a look at
- 7:53the trade it took. So, these
- 7:57lines, they do seem fine. Actually,
- 8:00let's rerun this with the 4 hours
- 8:03because I don't want to take that many
- 8:07trades. All right. So, this looks better
- 8:10even in the P&L number.
- 8:14So yes, it went long
- 8:18here and it sold it here. So I'm
- 8:21guessing yeah, because the closing price
- 8:23was here. So it opened it at this line
- 8:26at the line of uh
- 8:2961.8 and closed it at the Fibonacci line
- 8:32of
- 8:3323.6. So this seems perfectly correct.
- 8:37Now, of course, there are different ways
- 8:38for trading Fibonacci lines, but I think
- 8:41this is a good basic version of it. So,
- 8:43this is definitely a pass. Next, update
- 8:45my code to display the values of
- 8:47important indicators of my strategy in
- 8:49back test for debugging purposes. Now,
- 8:51for that, we're going to have to feed it
- 8:53a strategy. And I'm going to use this
- 8:55one from our website called alligator
- 8:57AI, which is free. So you just need to
- 8:59be logged in and click on the get
- 9:01strategy. Copy the whole thing and come
- 9:04here and paste it
- 9:08here. Let's see what it does. And notice
- 9:12that the strategy itself, it doesn't
- 9:14have the values for displaying the
- 9:17indicators on the chart, which is really
- 9:18helpful for debugging. And there we go.
- 9:21So it added an after method and it is
- 9:25using the add line to candle chart which
- 9:26is the correct syntax for the jaw teeth
- 9:29and lips of of the alligator. It's also
- 9:32doing the same for the long-term EMA for
- 9:35the CMO
- 9:36oscalator. This looks really perfect. We
- 9:38could also copy the whole strategy
- 9:40because sometimes it changes the names
- 9:42of some parameters. So it's better idea
- 9:45to just copy the whole thing. Paste it
- 9:48here.
- 9:49go back to Jesse and rerun this. Now,
- 9:53because it added just too many charts, I
- 9:56have to zoom out my page a little bit. I
- 9:58apologize for it, but at least we can
- 10:00see it now. So, here's the chart, the
- 10:03candlestick charts, and you can see the
- 10:05moving averages and the lines of the
- 10:07alligator indicator. And this one is the
- 10:11CMO. This one is the stoastic RSI. And
- 10:14you can also see that it defined the
- 10:16thresholds that we use in the strategy.
- 10:18the ADX again with the threshold of 30
- 10:23which you can find here and also the
- 10:25trend property which we defined which is
- 10:27either zero or one. You can also see it
- 10:30here. So this looks perfect. So this
- 10:32again is the pass. Next write a trend
- 10:35following strategy that uses 15 minutes
- 10:37time frame for entry and 4 hours time
- 10:39frame for confirmation. Right? So it
- 10:41defined the for candles like this using
- 10:44the get candles method and it hardcoded
- 10:47the time frame which is correct and then
- 10:49it's using that for moving averages to
- 10:52give us the long-term trend. All right,
- 10:54so this seems perfect. Let's go back to
- 10:56the code editor, paste the whole thing
- 10:59and rerun
- 11:00it. And there we
- 11:03go. It's also profitable with some good
- 11:06numbers. So this is also a pass. Next,
- 11:09here's the quote for my trend following
- 11:10strategy in the 15 minutes time frame.
- 11:13The strategy is losing money because it
- 11:15is taking too many trades and there are
- 11:16too many false breakouts during the
- 11:18ranging markets. Please improve the
- 11:20strate actually. Let's feed it the
- 11:21strategy that it just generated for us.
- 11:24But first, let's make sure that we are
- 11:26paying for trading fees because it was
- 11:28set to zero. So, let's run
- 11:33it. All right. So, the numbers are
- 11:35slightly different now. But also, let's
- 11:38lower the time frame to be 15
- 11:43minutes. And now we're not profitable
- 11:46anymore. We're taking 39 trades, which
- 11:49is indeed too many. But we're paying
- 11:51this much in trading fees. So, if we
- 11:53weren't paying fees, we would have been
- 11:55profitable. So, that's really the
- 11:57problem with the strategy right now. So,
- 11:58let's go here and just make sure there
- 12:01is no ADX. All right.
- 12:04So this is the only entry rule. We are
- 12:10using the ADX here and I don't want to
- 12:12do that because usually when I see a
- 12:14strategy that is taking too many trades,
- 12:16the first thing that I do is using the
- 12:18ADX indicator. But there are also some
- 12:20other methods and what I want to see is
- 12:23whether or not the model is capable of
- 12:25reasoning to know what a good strategy
- 12:28is to know what to do. So not just
- 12:30writing the ADX for me. I'm not going to
- 12:32tell it to do that. It needs to know
- 12:34that is a good idea for this case. So
- 12:36let's copy this. Remove
- 12:39it. And yes. So also remove it from
- 12:43here. Make sure it's not anywhere else.
- 12:46Let's go back and run it one more time.
- 12:49Now it's actually making a profit now.
- 12:52So that's a bit unexpected. So this is a
- 12:57exception case I guess because it
- 12:59increased the number of trades. But now
- 13:01we are even more profitable even though
- 13:04we are paying for fees. So here's the
- 13:06thing. Let's change the duration of this
- 13:09to two
- 13:12months. And now we are losing and we are
- 13:16also taking way more trades. So let's
- 13:18copy the
- 13:20strategy. Go to GSGPT and just paste the
- 13:23whole thing. All right. So let's copy
- 13:26the whole
- 13:27thing. Go back. Paste it here. And again
- 13:30it added an extra py here. So make sure
- 13:33that is removed. So let's check out the
- 13:36entry rule now. So it added a couple of
- 13:40things. So it's checking for market
- 13:42structure which is using the ADX
- 13:44indicator which is absolutely correct.
- 13:46It also added a volatility filters which
- 13:49is using the Ballinger bands width which
- 13:52is a perfect method actually one very
- 13:54subtle but effective which I also use
- 13:57sometimes it's checking for the momentum
- 13:59strength which is using the RSI and the
- 14:03MACD. All right. So it basically wants
- 14:07both the RSI and MACD to have certain
- 14:09conditions. It's wrote it in a a bit
- 14:11complex way. I don't love it but it
- 14:14should work. It's also checking for the
- 14:17price position which is using moving
- 14:21averages. It also added a time spacing.
- 14:24Okay. All right. So, this one is really
- 14:26good because it says a minimum of eight
- 14:29candles or 2 hours in this case because
- 14:32we're trading 15 minutes time frame must
- 14:34have been passed between trades to avoid
- 14:37overtrading. So this is also really
- 14:39effective and the way it does it is by
- 14:41saying if the current index minus the
- 14:43last trade index is bigger than 8. Now
- 14:46the current index is always updated
- 14:48behind the scenes by Jesse. So we just
- 14:51need to make sure the last trade index
- 14:53is also updated which it is doing that
- 14:58inside the unopen position. So when it
- 15:00opens a position it stores the value of
- 15:02the current index inside this variable
- 15:04so that we can later use it. So this is
- 15:07really beautiful code. So let's go and
- 15:10make sure it also
- 15:13runs and it
- 15:15doesn't. So this is really a shame
- 15:18because the syntax of it was really
- 15:21great so far. So let's see where it made
- 15:24the mistake. So it's basically here. All
- 15:27right. So it's passing the Ballinger
- 15:29band values to SMA getting the average
- 15:32of them. It looks fine but it's not
- 15:33running. And unfortunately, I'm going to
- 15:36have to give it a fail even though the
- 15:38code was really beautiful. All right,
- 15:40next. Develop a strategy that combines
- 15:42the Williams percentage R MACD and
- 15:45Ballinger bands. So, this is an easy one
- 15:48actually. All right, so let's copy the
- 15:50whole thing. Go back to my cursor
- 15:53editor, paste it, and remove this.
- 15:58So it defined the Williams percentage R
- 16:00with the syntax which is correct the
- 16:02MACD the Ballinger bands and these are
- 16:06the entry conditions. Now I like what it
- 16:08did with the comments and how it is
- 16:10defining the entry conditions because
- 16:13this is really easy for example if we
- 16:15need to remove one of them or add it
- 16:17again. So and the comments are also
- 16:20really helpful for the
- 16:21user. All right so this looks perfectly
- 16:24fine.
- 16:26Everything else is also correct. I like
- 16:29the definitions here. All right. So,
- 16:31let's go and make sure it
- 16:37runs. And there we
- 16:39go. Now, if we run it on the 4
- 16:45hours, it is now profitable and it took
- 16:49six trades. So, this is definitely a
- 16:51pass. All right. Next, write the entry
- 16:53functions of the strategy for me in a
- 16:55way that it should use two limit orders
- 16:57for opening the position and it should
- 16:59only risk 2% of the capital per trade.
- 17:02So, here's the thing. So far, with every
- 17:04strategy that we wrote, it was using
- 17:06market orders for entering and also in
- 17:08just one point. And what I want to see
- 17:11if the model gets how we can do it with
- 17:13multiple points using limit orders. So,
- 17:16let's hit enter. And it just wrote that
- 17:19function. So it is also listening to
- 17:21what I said. It didn't write the whole
- 17:23strategy and the example it is using it
- 17:28is using the ATR which makes perfect
- 17:30sense. It also did the same for a stop
- 17:32loss. For the quantity it is risking 2%
- 17:36using the risk to quantity utility
- 17:38function of Jesse. So that's also
- 17:40perfectly correct. It is entering with
- 17:4260% of the capital for the first order
- 17:46and the second one for with 40%. And it
- 17:49is using the correct syntax which is
- 17:51this. So in Jessie if we want to submit
- 17:54more than one order we don't just enter
- 17:56it with quantity first and then the
- 17:58price. We need to define a list of tulip
- 18:02values. And that's how it did it which
- 18:04is perfectly correct. So this is also
- 18:06definitely a pass. And last and
- 18:08definitely not least write a parading
- 18:11strategy for ETH and BTC. So this is a
- 18:14tough one because it needs to write two
- 18:16strategies and also guide us on how to
- 18:18run it because we want to long one
- 18:20strategy while we short the other one.
- 18:22Now if you don't know what type of a
- 18:23strategy I'm talking about, watch my
- 18:25previous video here where I described
- 18:27how Edward Torb used this strategy to
- 18:30make his 800 million fortune. All right,
- 18:32so here's a pair trading strategy for
- 18:34ETH and BTC. You'll need two strategy
- 18:36files and two routes configured. So
- 18:38that's correct. So the first one is the
- 18:41leading strategy for BTC route. So let's
- 18:44copy it. Go to Jesse and define one.
- 18:47Let's call it
- 18:50claude pairs
- 18:52one. And another one
- 18:56for
- 18:59claude pairs
- 19:02two. Now for the first one, let's paste
- 19:05it here. All right. So this is the first
- 19:07one.
- 19:09This is the second one which is the
- 19:10follower strategy. So let's also copy
- 19:12this one but also let's read what it
- 19:14says. So route configuration configure
- 19:17two routes in J. Route one is for BTC
- 19:20which is the leading and route two is
- 19:23EUCT which is the following how it
- 19:25works. Calculate Z score of BTC and ETH
- 19:28price spread. Enters positions when
- 19:30Zcore exceeds plus or minus 1.5
- 19:33threshold. Exis when Zore returns to
- 19:35neutral. checks configuration daily to
- 19:37ensure pairs relations exist. Uses
- 19:40volatility based position sizing for
- 19:42optimal risk distribution. BTC route
- 19:45leads all decisions and communicates via
- 19:47shared VS. Now in case you're not
- 19:49familiar in Jesse, if you have more than
- 19:51one strategy and if those strategy files
- 19:54need to communicate with each other, we
- 19:56need to use the shared VS variable which
- 19:58can be accessed from any file. And this
- 20:01is brilliant. So let's go back to Jesse
- 20:04and go to the second pair and paste it
- 20:08here. Now if I go to the back test page
- 20:11and let's add another trading route and
- 20:15this one is cloud pairs one cloud press
- 20:192. This one must be
- 20:22ETC. So let's run it. Now it's telling
- 20:26me that I cannot run it because the fast
- 20:28mode is on. So in case you don't know
- 20:30the fast mode is really great but it
- 20:32doesn't work when you are dealing with
- 20:33multiple routes. So this should be fine
- 20:36now. Let's run
- 20:37it. All right. So we're getting this
- 20:40these errors. Let's cancel it and go and
- 20:44check the code. So the way it defined
- 20:46the get candles. So instead of this it
- 20:49should have
- 20:50said self exchange so that it would have
- 20:54worked anywhere. I think that's why we
- 20:55were getting
- 20:57that. Yeah. So now it actually crushed
- 21:00it. So it made one tiny mistake.
- 21:02Otherwise, it was great and it was even
- 21:05profitable with some really good
- 21:07numbers. Now, unfortunately, I'm going
- 21:08to have to give it a fail, but it did a
- 21:11pretty good job. It just made one tiny
- 21:13mistake. So, here's the overall result.
- 21:15And even though it failed in three
- 21:17questions, it actually did make them. It
- 21:20just made one really tiny mistake. So,
- 21:22I'm not even sure if I had to give it a
- 21:24fail. Now, this was a new type of video
- 21:26that I just did. If you guys have any
- 21:28feedback, especially for the questions,
- 21:30maybe you have some other questions you
- 21:32want me to ask the model or maybe we
- 21:34need to change the rating system, just
- 21:35let me know by posting a comment on the
- 21:37video. And before I leave you, we're
- 21:38going to have a giveaway. A random
- 21:40person who likes the video, post a
- 21:42comment, and subscribes to the channel
- 21:44is going to win 1 million bunk token.
- 21:46All right, let's pick the winner from
- 21:47the previous video. And the winner is,
- 21:50"Thanks for a new strategy to test out.
- 21:52Thank you so much for your comment.
- 21:53Please reach out to me so that I can
- 21:54send you your bank tokens." Thanks for
- 21:56watching and I'll see you in the next
- 21:58one.
- 21:59[Music]
- 22:00[Applause]
About this transcript
This page contains the full transcript of Claude 4 tested: Good for algo-trading strategies? by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 3,728 words across 532 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.