GPT: KAMA Scalping Strategy in Python Makes 795% — Transcript
Full transcript
- 0:01hey guys Sol today I'm going to act as a
- 0:03Trader who has a good strategy but maybe
- 0:05he's not necessarily a good programmer
- 0:07so I'm going to ask our GPT to write the
- 0:10code for me now of course I'll be there
- 0:12guiding it if it makes any mistakes but
- 0:14I'll do my best not to touch The Code by
- 0:16myself now the main indicator that I'm
- 0:18using in this strategy has become my
- 0:20most favorite indicator so far it be
- 0:24super Trend moving averages or anything
- 0:25else that I used before all right let me
- 0:27show you why
- 0:30the main indicator of this strategy is
- 0:32called kofman adaptive moving average
- 0:34don't let the name scare you it's
- 0:36actually very simple to use so basically
- 0:38when the line is red we're in a
- 0:40downtrend when it's green we are in an
- 0:42uptrend in other words when the current
- 0:44price is below the moving average we're
- 0:46in a downtrend when it's above we're in
- 0:48upt all right this is important because
- 0:50that's how we're going to write the code
- 0:52but the really cool thing about this is
- 0:54that it actually reacts to the price
- 0:56very quickly to compare let's add the
- 0:58super Trend which used to be my favorite
- 1:00indicator for Trend following notice
- 1:02that in this uptrend the super Trend
- 1:04started getting green in here while the
- 1:08cman moving average actually gave us the
- 1:10signal here so that's like eight or 10
- 1:13candles before that it's also the same
- 1:15in here so the super Trend it started
- 1:18getting red in here but the kman moving
- 1:21average or comma in short it started
- 1:23giving us that signal here right in here
- 1:26I'm look at this the comma started
- 1:28getting green here but the super Trend
- 1:31gave us the signal here you see the
- 1:33difference is really huge all right so I
- 1:35simply asked GPT to write a trend
- 1:37following strategy using the comma
- 1:39indicator to determine the trend
- 1:41Direction risk 3% per trade which is
- 1:43what I usually do set the suplus and
- 1:46take profit at 2.5 times of the current
- 1:49ATR which again is something that I do
- 1:51in many strategies this is the code that
- 1:52it gave me so first let's copy the name
- 1:55and go to Jesse and create a new
- 1:57strategy with the same name and then I'm
- 2:00going to copy the whole thing and open
- 2:02my IDE and I'm going to paste the whole
- 2:05thing and I'm also going to zoom so it
- 2:08would be easier for you guys to see so
- 2:09let's go through it one by one so first
- 2:12it Define a new property for the comma
- 2:13indicator and the syntax is perfectly
- 2:16correct then it defined the ATR now it's
- 2:19simply saying ta. ATR then this is
- 2:22passing the current candles again
- 2:23perfectly fine for the shoot long which
- 2:26is our entry rule it is saying return
- 2:28true if the the current price is above
- 2:31the comma line this is exactly what I
- 2:33said that when the current price is
- 2:34above this line we are in uptrend and
- 2:37vice versa for short positions so that's
- 2:40exactly what it is doing here and once
- 2:44the entry rules are met we're going to
- 2:46use the go long method to open the long
- 2:48position and the go short for the short
- 2:50position and it's saying that the inter
- 2:52price is the current price which would
- 2:54be a market order and that's exactly
- 2:55what I wanted the sub plusus is the
- 2:57current price minus 2.5 * h
- 3:00which again is what I specified for it
- 3:03and for the quantity it's using the risk
- 3:05to quantity utility function of JC which
- 3:07first you will pass the available margin
- 3:10or your capital and then the percentage
- 3:12risk and that's three which is what I
- 3:15asked in my prompt then the entry price
- 3:18the suplus which it calculated here and
- 3:20then passing the current fee of the
- 3:22exchange for trading and finally it is
- 3:24submitting the buy order and to do that
- 3:27is first is passing the quantity and
- 3:29then the entry price right so then it's
- 3:31doing the opposite for short positions
- 3:33and now we need to submit the stop loss
- 3:36and take profit at some point right and
- 3:38it's doing that right after we open a
- 3:40position so using the unopen position
- 3:42event we're saying if it's a long
- 3:44position I want the Stop Plus to be the
- 3:47quantity of my current position and the
- 3:50price is going to be the current price
- 3:51minus 2.5 * the current ATR and we're
- 3:55doing the opposite for a take profit now
- 3:57this is exactly what I asked in my
- 3:59prompt and it wrote it perfectly fine
- 4:01and it's doing the opposite for short
- 4:03positions it also defined the update
- 4:05position method which is used sometimes
- 4:08for for example saying if it's a long
- 4:10position and the current price is below
- 4:12the comma line in other words when it's
- 4:14the opposite of our inter rule I want to
- 4:16liquidate the position now I tried this
- 4:18and it didn't work fine with this
- 4:19strategy so I don't want it to be here
- 4:22right and it's not what I asked in the
- 4:23prompt all right so let's go to Jesse to
- 4:25the back testing section and choose our
- 4:28strategy and as for time frame I will
- 4:30begin with 15 minutes the symbol is BTC
- 4:33UCT the duration I'm beginning since
- 4:352022 up until just a few days ago and
- 4:40I've also selected the fast mode and The
- 4:42Benchmark right so we should be able to
- 4:45start the first practice while this is
- 4:47going I'm going to add another one and
- 4:49pick the 30 minutes time frame and then
- 4:52another one for the 1
- 4:54hour and another one for 4 hours all
- 4:58right so let's take a look at The
- 5:00Benchmark page this is for the 15
- 5:02minutes which is absolutely horrible but
- 5:04that is basically because we're taking
- 5:05just too many trades and we probably
- 5:08paying just too much trading fees I look
- 5:10at it here we're paying 12,000
- 5:13fees while the starting Capital was just
- 5:1610,000 so obviously we need some filters
- 5:19now this is for 30 minutes it looks
- 5:20better because we're taking less trades
- 5:22this is for hourly and 4 hours all right
- 5:25so at this point I went back to GPT and
- 5:28I said remove the object position part
- 5:30which is what I didn't want to do
- 5:32because I didn't ask you to do that and
- 5:34I also add the adx filter so that I
- 5:36don't want the strategy to take any
- 5:37trades if the adx is below 50 now I
- 5:40always use the adx filter when I want to
- 5:43avoid taking a trade when the market is
- 5:46ranging which is what we always want to
- 5:48do with Trend following strategies so
- 5:50this is the code that it gave me let's
- 5:53go back paste it in now firstly it
- 5:55removed what I asked it to remove but it
- 5:57did add the shoot cancel entry method
- 5:59which we don't really need in this
- 6:01strategy because we are using a market
- 6:03order here to enter the position so
- 6:06there isn't any entry to cancel or not
- 6:08right so we can just remove this now it
- 6:10also added the adx property using the
- 6:14ta. adx and then it just passed the
- 6:16candles using the default parameters
- 6:18which is exactly what I wanted and then
- 6:21in my entry rule it added this one it's
- 6:24saying and self. adx is above 50 and
- 6:28it's doing the same thing for short
- 6:29positions so this is perfect let's go
- 6:32back to Jesse and run another back test
- 6:35so while this is going I wanted to
- 6:36quickly remind you guys that we have a
- 6:38Discord Community with more than 3,000
- 6:40quants such as you and I we hang out
- 6:42there share ideas and help each other
- 6:44out and I would love to see you guys
- 6:45there all right so the result looks
- 6:47significantly better this is for 1550
- 6:49minutes this is for 30 minutes this is
- 6:52hourly and this is for 4 hours so you
- 6:55can see we're actually profitable at
- 6:57this point right especially with the 4
- 6:59hours now the main reason that we got
- 7:02profitable at this point is that instead
- 7:04of trading thousands we are trading just
- 7:07573 trades so we're not paying as much
- 7:10in trading fees anymore although it's
- 7:12still by the way we're paying 7,000 in
- 7:15trading fees imagine if this was added
- 7:18to our ending balance we would have been
- 7:20sitting on a really nice profit so at
- 7:22this point I went back to GPT and I
- 7:24asked it to do something that I always
- 7:26do so basically whenever I have an
- 7:28indicator that I really like it usually
- 7:31works really well if I use the same
- 7:34indicator as it is but also on a bigger
- 7:37time frame all right so let me show it
- 7:39to you here so this is the comma
- 7:42indicator that we are using now I just
- 7:44added another one now because it doesn't
- 7:47have the option to set time frame in it
- 7:50because it's a community built indicator
- 7:52what we can do instead is to just
- 7:54increase the length from 14 to let's say
- 7:58250 but in Jesse we can specify the time
- 8:01frame and that's what we're going to do
- 8:02so check this out so this means we now
- 8:05have two integrals not just one so for
- 8:08example in here this comma line went
- 8:11green but this one was still red so
- 8:14because of that we did not take the
- 8:16trade now maybe this isn't really a good
- 8:18example of it but in here for instance
- 8:21here it became red but we're not taking
- 8:24a short position because the below one
- 8:26or the slow one the one with the bigger
- 8:28time frame is green so because they are
- 8:31not saying the same thing we're not
- 8:33going to take any trades and as a result
- 8:35it wouldn't have been a false breakout
- 8:37here all right so I simply ask GPT this
- 8:39is good but firstly remove the shoot
- 8:41cancel inry method because we don't need
- 8:43it and I need you to Define another
- 8:46property for the direction of the trend
- 8:48again using the comma indicator except
- 8:51this time use the bigger time frame
- 8:52candle use the 4 hours as a bigger time
- 8:54frame but if the current trading time
- 8:56frame is 4 hours itself then use the 6
- 8:59hours now this is the code that it gave
- 9:01me all right so first it defined a new
- 9:04property called the long-term candles so
- 9:06instead of passing the candles like this
- 9:08for this case we're going to pass the
- 9:10long-term candles and in it it said that
- 9:12the big time frame equals 4 hours but if
- 9:15the current time frame is 4 hours then
- 9:17the bigger time frame is 6 hours and
- 9:19then it's using the get candles built in
- 9:21method of Jesse which will give us the
- 9:23candles for whichever exchange we tell
- 9:26it to whichever symbol and time frame
- 9:28and it is passing this variable as a
- 9:30time frame all right and then it defined
- 9:34another one called long-term comma which
- 9:37is just using that and then it defined
- 9:40another property called Trend Direction
- 9:42which is using that to determine the
- 9:45trend but the weird thing is that it is
- 9:47not using this or anything else inside
- 9:50our actual iny rule so it's flood so I
- 9:53went back to it and I just said this is
- 9:55good but we're not using the value of
- 9:57the trend Direction in your ined rules
- 9:59also in it go ahead and just put the
- 10:01part where we checked the direction of
- 10:02the trend using the self comma also in
- 10:05it so that our shoot long and shoot
- 10:06short would be cleaner so this is the
- 10:09correction that it gave me and now if
- 10:12you check it again that property doesn't
- 10:14exist but instead inside our shoot long
- 10:17and shoot short it is using this line to
- 10:20check for the direction of the trend
- 10:22with the longterm comma now let's go
- 10:24back to Jesse and rerun the entire back
- 10:28test now remember these numbers so the
- 10:29sharp here is 0.6 1.2 right so the
- 10:33results are slightly improved not too
- 10:35much but they are especially with the 30
- 10:38minutes I like this Equity curve better
- 10:41right so now I want to add another
- 10:43indicator which is very similar to adx
- 10:46except it kind of works the opposite so
- 10:48with the adx we want the volatility to
- 10:50be high to take a trade so that's why we
- 10:52say take the trade if the adx is above
- 10:5550 but with the chop index index it's
- 10:58actually the opposite we want want the
- 10:59choppiness or the randomness of the
- 11:01market to be low and the way it works is
- 11:03that we Define some kind of threshold
- 11:06usually at number 50 and we want the
- 11:10choppiness to be below that so here for
- 11:12instance you see it was in a ranging
- 11:14Market which means it was random the
- 11:17choppiness was high and you can see it
- 11:19in here the number is actually above our
- 11:22threshold but here which we had some
- 11:25kind of trend the value for the chop
- 11:27index is actually low the same goes for
- 11:31here actually so we were just beginning
- 11:33to see some structure but then again we
- 11:36went into range so the value is is
- 11:38clearly seeing that no the market is
- 11:40just randomly working so that's why I
- 11:42really like this indicator for trending
- 11:44strategies so I went back to Jesse and I
- 11:47said add another filter for our in rules
- 11:50I want to take only positions when the
- 11:51choppiness index is below 50 and this is
- 11:54what it gave me right so it defined a
- 11:57new property called Chop and in it it
- 12:00said ta. chop and then pass the current
- 12:02candles all right so it also reformatted
- 12:05our inter rules and I really like it
- 12:07this way because you can clearly see we
- 12:09have four in rules for the strategy in
- 12:12the end of it it said the self the chop
- 12:14is below 50 it also did the same thing
- 12:17for short positions all right so let's
- 12:18go back to Jesse now remember these
- 12:20numbers sharp is 0.9 1.1
- 12:250.7 so let's reexecute everything one
- 12:28more time right so check this out the
- 12:30sharp ratio of all the time frames is
- 12:32now improved so with the 15 minutes now
- 12:34we have a sharp of one with 30 minutes
- 12:36we have 1.3 so let's take a look at the
- 12:39equity curve so it looks slightly better
- 12:42this is for 30
- 12:43minutes and this is for hourly and this
- 12:47is for 4 hours all right so this is
- 12:49really cool but now I want to show you
- 12:51another technique that I use with this
- 12:53sub of strategy so you see sometimes
- 12:55there is a trend for example in here but
- 12:58because there was such a huge jump in
- 13:00the price like out of nowhere we don't
- 13:02really want to take the position here
- 13:04because there's a good chance that there
- 13:06will be a pullback now how can we know
- 13:08about this one way is to use the
- 13:10Ballinger bands indicator and if you
- 13:12take a look while this was the case the
- 13:15width of the Ballinger bands so the
- 13:17difference between this line and this
- 13:19line is actually really low but during
- 13:21here when the price had a huge surge the
- 13:24difference is really huge right you can
- 13:27see the same thing here for instance so
- 13:29we don't really want to take a trade
- 13:31here because now the difference between
- 13:32the upper and lower band of the
- 13:34Ballinger bands is really huge that
- 13:36means that the price is just moving too
- 13:39much and it has already went up too much
- 13:41and if you take the trade here there's a
- 13:44good chance there's going to be a
- 13:45pullback and we're going to end with a
- 13:46loss now how can we measure this well
- 13:49there's a really easy way and that is to
- 13:51use another indicator called the Binger
- 13:53band WID now with this one what we get
- 13:57is actually just what I describ which is
- 13:59the difference between these two lines
- 14:01and for instance in here which you can
- 14:03see it's really tight the value for this
- 14:06is almost one but in here the value goes
- 14:09up to near nine right so it's really
- 14:13huge and in this line that I said you
- 14:15know we don't want to take the trade the
- 14:16value is almost at seven so now I asked
- 14:19GPT to add another filter using the
- 14:22Ballinger band with value and I said I
- 14:24want to take a trade only if the value
- 14:26of it multiplied by 100 is below 7 now
- 14:29why did they ask it to be multiplied by
- 14:31100 that's because in the calculation
- 14:34that the trading view is using that's
- 14:35what they're doing they are multiplying
- 14:37it by 100 otherwise this value would
- 14:39have been 0.07 instead of just 7 which
- 14:42is just really easier on the eyes
- 14:44because I want it to be the same as
- 14:46trading view I just asked it to multiply
- 14:48it by 100 all right so let's copy this
- 14:50go back paste it
- 14:53here and now we have a new property
- 14:56called BB width and in it is using ta.
- 15:00Ballinger bands and it's actually
- 15:01calculating the value of the BB width
- 15:04that I wanted instead of using the
- 15:06builtin indicator that Jessi has for
- 15:08this indicator so I went back and I
- 15:10simply asked that this seems fine but I
- 15:12need you to use the built-in volunteer
- 15:14bands with indicator of Jessi it gave me
- 15:16this one which is indeed using the
- 15:19Ballinger bands with built-in indicator
- 15:21of Jessi and in the in rule it's saying
- 15:25that the value of it multiplied by 100
- 15:28must be below seven and it's using the
- 15:30same thing for a short position all
- 15:32right so there's one more filter that I
- 15:33wanted to add you see sometimes we take
- 15:35a trade and it actually goes really well
- 15:37we close the position but we're kind of
- 15:39done with that Trend especially because
- 15:41this is a scouting strategy we want to
- 15:43get in and out very quickly so we don't
- 15:45want to write the trend for for for
- 15:47example for as long as possible but
- 15:49sometimes our in rules are still true so
- 15:52that means even though the strategy
- 15:54closes one trade it immediately takes
- 15:56another one so I wanted to implement
- 15:58some kind of tool off mechanism so I
- 16:00went back to GPT and I said lastly add
- 16:02another inry rule I need the strategy to
- 16:05remember the last index that it took a
- 16:07trade and when a trade is over I don't
- 16:09want to take another trade until at
- 16:11least another 10 candles has been passed
- 16:14so let's copy this all right so first it
- 16:16Define a new variable because we're
- 16:18going to need to hold the value of that
- 16:20index it's called last trade index and
- 16:22then in our entry rule it said if the
- 16:25current index minus the last trate index
- 16:28is bigger or equal to 10 which is
- 16:31exactly what I wanted it also did the
- 16:32same thing for our Sho short method but
- 16:35where is it updating this because we
- 16:37need to specifically update this it's
- 16:39doing that inside the go long and go
- 16:41short method so once we are opening the
- 16:44position it is updating this value using
- 16:47the current index now this line is
- 16:51perfectly correct but there is one
- 16:53mistake at this point we are just
- 16:55opening the position but I wanted to
- 16:59wait 10 candles after we close the
- 17:01position all right so this ISS to change
- 17:04so I went back and I told it that you
- 17:06are updating the last index inside the
- 17:08go long and go short methods but that's
- 17:10for when we are opening the position I
- 17:12need you to update it inside the on
- 17:15close position method instead and it
- 17:17gave me this
- 17:20one so now it added another method
- 17:23called on close position which is a real
- 17:26event method inside Jesse and in it is
- 17:28saying that I want to set the current
- 17:30index inside the last word index
- 17:33variable which is exactly what you
- 17:34wanted and it removed that other one all
- 17:37right perfect so let's go back to Jesse
- 17:40and run another back test so remember
- 17:42these numbers the sharp is one 1.3 1.1
- 17:46and
- 17:471.1 all right check this out the sharp
- 17:51is upgraded to 1.9 on the 15 minutes
- 17:55time frame and the Cal R is 3.7 which is
- 17:58amazing and the max thron for almost all
- 18:01of them is below 10% that's just awesome
- 18:04with the 30 minutes it's 1.3 which is
- 18:06still awesome so let's take a look at
- 18:09the equity curve this looks
- 18:12fantastic and this is on the 30 minutes
- 18:15now you may think that this is a
- 18:17straight line but it's not actually it
- 18:20is still going up and because the max
- 18:22thron is really low we can simply add to
- 18:25our position size so that this would
- 18:27look better now this is with the hourly
- 18:30and this is with the 4 hours now the
- 18:32hourly and the four 4 hours I think
- 18:34should be retired at this
- 18:36point but these two look really well but
- 18:39the max Ron is still really low so that
- 18:41means we can easily add to size of our
- 18:44position so if I go back and in here for
- 18:47instance I can just add to this quantity
- 18:50by number such as let's say three and
- 18:53rerun the two of them all right so now
- 18:55with the max throw down of minus 24%
- 18:57we're making nearly
- 18:59800% profit all right so this is the
- 19:02equity curve now obviously this looks
- 19:05still really good and this is with with
- 19:08the 30 minutes now you see my point it
- 19:10wasn't really a straight line it is
- 19:12still going up but we weren't really
- 19:15seeing it because there wasn't enough
- 19:16volatility in the daily balance but now
- 19:19that we added to the position sides it's
- 19:21much more but still these Max R numbers
- 19:24I think it's really safe to just
- 19:26increase them because my risk cap allows
- 19:29me to take up onus 30% Max R down and if
- 19:32we do that we're going to make even more
- 19:34penal numbers in here you can access the
- 19:36source code of this strategy on our
- 19:38website if you haven't checked out this
- 19:39page yet now is the time to do so there
- 19:41are tons of other strategies in here and
- 19:43you can very quickly see the results of
- 19:45each strategy on various periods and
- 19:47symbols and time frames now this was a
- 19:50new type of video that I just did where
- 19:52the idea of the strategy was from me but
- 19:55the implementation was done by the AI
- 19:57while me being the teacher and guiding
- 19:59it now if you like this format please
- 20:01let me know and if you didn't if you
- 20:02want me to go back to the previous
- 20:04format where I take the idea let's say
- 20:06from the AI but I called it from a
- 20:07scratch myself again please let me know
- 20:10now we're going to have a giveaway a
- 20:11random person who likes this video posts
- 20:13a comment and subscribes to the channel
- 20:15is going to receive 1 million bnk token
- 20:18all right let's pick the winner for my
- 20:19previous
- 20:21video and the winner is amazing results
- 20:24well done thank you so much for your
- 20:26comments please reach out to me so that
- 20:27I can send you your buk tokens thanks
- 20:29for watching and I'll see you in the
- 20:31next one
- 20:32[Music]
About this transcript
This page contains the full transcript of GPT: KAMA Scalping Strategy in Python Makes 795% by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 3,994 words across 526 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.