ChatGPT is the future of trading. Learn how to leverage its power to create profitable strategies and achieve financial freedom. And yes, both this insane trading strategy and this description were generated with ChatGPT.
Ensure you watch until the end where I explain the goal of this video: to help non-programmers learn how to backtest trading strategies. This strategy is overfitting and won’t work.
Instead, try to backtest your own strategy or other strategies to see if they make sense.
THERE ARE NO SHORTCUTS IN TRADING
The only shortcut for most is to invest in an index and do something else that makes you money.
🔗Follow along and download the code: https://analyzingalpha.com/dominate-the-markets-with-chatgpt-and-tradingview
👍 Subscribe for more: https://bit.ly/3lLybeP
⏱️ Video Chapters
0:00 Introduction
1:38 Intro to TradingView & Pinescript
Show More Show Less View Video Transcript
0:00
hello everyone today we're going to take
0:01
a thousand dollars and turn it into over
0:03
more than one million by using open ai's
0:06
chat GPT to develop a Bitcoin trading
0:10
strategy for us there's only one problem
0:12
is that I didn't prepare for this video
0:14
but then again why would I I can just
0:16
pass chat GPT to create an outline or an
0:20
introduction for me let's see how it did
0:22
hi there and Welcome to our tutorial on
0:24
using chat GPT to develop trading
0:26
strategies in this video I'll be showing
0:29
you how to use chat gbt a powerful
0:31
language model developed by open AI to
0:33
create custom trading algorithms without
0:35
any programming experience whether
0:37
you're a seasoned Trader looking to
0:39
automate your trading strategy or
0:40
complete beginner looking to learn about
0:42
trading this video is for you so sit
0:44
backs and and relax and get started with
0:48
chat GPT so pretty darn good right so
0:50
essentially we can use natural language
0:52
or simply ask the computer something it
0:55
can then take that something and
0:58
translate it into computer code and give
1:00
us an answer back now in regards to
1:02
trading we can have non-traders ask hey
1:06
give me a momentum strategy using these
1:08
parameters and it'll do it for us and
1:10
you can actually use tools like training
1:12
view which already has the data and
1:14
everything built in to test it for this
1:16
channel typically I'm building databases
1:18
by doing python all this other stuff and
1:20
sometimes that's not very accessible to
1:22
many Traders but this really opens up
1:26
the door for anyone who wants to be able
1:28
to create a profitable trading strategy
1:30
based on back test and in this video I'm
1:32
going to teach you exactly how to do
1:34
that so that way you have confidence
1:36
when going into your future trades
1:38
now the first thing that we're going to
1:39
want to do is go over to tradingview.com
1:42
tradingview.com is the world's most
1:44
popular online trading platform you can
1:47
chart pretty much the price of anything
1:48
but there's also Community tabs there's
1:51
news feeds there's also custom
1:53
indicators and even mobile phone alerts
1:55
but for our intents and purposes we are
1:58
going to be using the strategy tester
2:00
and coding in Pine script so you want to
2:03
go down here and click on the pine
2:04
editor here you may see a blank strategy
2:07
if you don't just go to open and then
2:09
click create new strategy and here will
2:11
be the boilerplate code but again don't
2:13
worry we're not really going to be doing
2:15
the coding chat GPT we'll be doing that
2:18
coding for us so let's head back over to
2:20
chat GPT and create our first trading
2:22
strategy now the biggest challenge any
2:25
new user of chat GPT or any other NLP
2:28
model is going to face when creating a
2:30
trading system is articulating exactly
2:32
what they want if you want a 50-day
2:34
simple moving average you have to tell
2:36
chat GPT that it cannot read your mind
2:38
if you want chat gbt to give you a
2:41
trading strategy using a crossover of
2:43
the 12 and 26 EMAs well fantastic but
2:46
you have to be explicit about it in our
2:48
case we want to start off as simple as
2:50
possible so I'm going to tell chat GPT
2:52
exactly that right give me an extremely
2:56
simple long-only trading strategy that
3:00
uses the 50 SMA
3:03
in Pine script V5
3:08
and now the great thing about chat GPT
3:10
is it'll actually explain what it's
3:13
doing and then provide you the code
3:15
sometimes the explanations at the top
3:17
sometimes at the bottom and usually it's
3:19
well commented so we're going to copy
3:21
this code and then we're going to take
3:22
it into trading View and run it now all
3:25
we need to do to get this code to
3:27
compile is paste it into the pine editor
3:30
and click save if you don't have your
3:31
Pine editor open you'll want to click
3:34
the pine editor down at the bottom of
3:36
your screen here and then if you don't
3:38
see any code here click open and create
3:41
new strategy and this is the boilerplate
3:43
strategy now we can go ahead and paste
3:46
all of our code from chat EPT here click
3:50
save and unfortunately we'll just call
3:53
this a chat GPT Bitcoin strategy
3:58
it doesn't work it says try to add this
4:01
or that so let's undo this I know it
4:04
doesn't have this strategy code here
4:07
which we we need for it to run so I'm
4:09
going to paste the code under here and
4:12
then click save and we're going to start
4:13
seeing more errors because we're not
4:15
using ta now you're going to say wow I
4:19
thought that chatgpt was going to be the
4:21
new thing and now I have to like figure
4:23
out how to code I have to troubleshoot
4:25
all this well
4:26
no you don't there's actually a better
4:28
way to do this now it's essential to
4:30
understand that chat GPT is good at
4:32
creating code or content from scratch
4:35
but it's much much better at taking
4:37
existing content such as you know
4:40
natural language or code and improving
4:42
upon it we use chat EBT to kind of
4:45
research an idea of what we want and
4:47
then we can go to the public library of
4:50
strategies provided by training View and
4:53
iterate or approve upon it so you can
4:55
see here I can click on this bar up down
4:58
strategy and you know it looks like it's
5:01
losing some money but you know maybe
5:03
this is something that we're interested
5:04
in we can go up here click the brackets
5:08
here for the source code
5:10
take this
5:12
copy it go back to chat GPT say please
5:16
explain this
5:19
Pine script through me
5:23
and it will actually tell you what it
5:26
does so if you have a question on how a
5:28
strategy works because you don't
5:29
understand the code yet you can use chat
5:31
GPT and one crazy thing that happens is
5:34
after you do this for a while you'll
5:36
actually be able to read this code now I
5:39
don't want to use this bar up down
5:41
strategy let's take a look at some other
5:42
strategies here's some Bollinger band
5:44
strategy so I'm going to look for a few
5:46
or strategy that actually performs well
5:49
you know
5:50
you know that's a almost one percent
5:53
stochastic
5:55
super Trend okay so it looks like we got
5:58
a winner the super trend is up
6:00
478 percent so we'll start with the
6:03
super Trend indicator to see if we can
6:05
get it to over a million so we'll click
6:08
on indicators
6:10
go to super Trend and here we have it
6:12
and now we can go ahead and grab this
6:14
code
6:17
I'll say I'm just hitting Ctrl a and
6:19
Ctrl C or you can select the whole thing
6:21
cut copy and I'm going to go to open
6:25
strategy
6:26
I'm going to then paste this save it and
6:30
I'm going to call it super trend
6:33
Bitcoin strategy and click save we need
6:37
to get an understanding of the super
6:38
Trend strategies return profile when
6:41
trading Bitcoin we know that when we
6:43
went to the indicator library and
6:44
selected strategies that it was one of
6:46
the best performing strategies if not
6:48
the best performing strategy available
6:49
to us but without actually looking at
6:52
the returns we don't know how to
6:54
optimize it we can do that by going to
6:57
strategy tester we can see an overview
6:59
here where we can see a pretty nice
7:01
Equity curve a pretty large drawdown you
7:04
know we've got 52 average bars in a
7:07
trade with 79 total closed trades and 44
7:09
be profitable if we go to Performance
7:12
summary we can see a glaring issue that
7:14
we can potentially fix I'll zoom in to
7:16
make it a little easier to see but
7:18
basically we're making a lot of money on
7:21
the long side and losing a lot of money
7:23
on the short side now not only are we
7:26
losing this money but it's not available
7:28
to us on the long side to compound so
7:30
what we'll do is we'll change this
7:32
strategy from a long short strategy to a
7:36
long only we can do that by going to the
7:38
Pine editor selecting all of this Ctrl a
7:41
and control C or you know selecting all
7:43
of it and clicking copy and then what
7:45
we're going to do is we're going to go
7:47
to chat GPT and ask it to close the
7:51
position whenever the super Trend
7:53
strategy changes Direction instead of
7:57
shorting so let's reiterate that to chat
7:59
GPT we'll say update the following
8:01
hindscript to close long entries
8:06
instead of going short then I'll paste
8:09
the code and henceforth I'm going to
8:11
just show you what I type into chat GPT
8:13
and then I'll fast forward to the output
8:15
so I'm not wasting your time we'll take
8:17
the code we'll copy it and then we'll
8:19
paste it back into trading View Press
8:21
Ctrl a in the pine editor then Ctrl V to
8:24
paste it we see that our code is updated
8:27
we then press save to try to compile it
8:29
we don't see any errors which is
8:31
fantastic which means we think that chat
8:34
GPT successfully changed our code simply
8:37
by us giving it Direction now let's
8:39
validate that these strategy results are
8:41
improved we should see that there are no
8:43
losses on the short side or even no
8:45
trades on the short side we go to the
8:47
strategy tester we then can look and see
8:50
that our strategy did change we now have
8:52
a 55 percent win percentage and
8:55
underperformance summary we don't see
8:57
any short losses now I promised you that
9:01
we're going to take a strategy from 1
9:03
000 to well over 1 million so now what
9:05
we're going to do do is update the
9:07
initial Capital to see how far away from
9:10
that Target we are
9:13
but we're not going to use chat GPT for
9:15
this because I don't want to do you a
9:17
giant disservice recall earlier that I
9:19
said the most challenging thing a new
9:21
Trader will encounter when trying to
9:24
create a trading strategy with an NLP
9:26
model like chat GPT is articulating
9:28
exactly what they want and if you're not
9:31
able to at least get the information out
9:33
of pinescript that you need you're not
9:36
going to be able to design the trading
9:38
system that you want but don't worry all
9:41
you need are two fingers right it's not
9:44
difficult you can see these blue
9:46
keywords remember we're taking existing
9:49
strategies and indicators out of the
9:50
library pasting what we want or asking
9:52
Chachi PT to modify them and then what
9:55
we can do is find these blue keywords we
9:57
just press control and click and we'll
9:59
pull up the pine script reference manual
10:02
and then you can see all of these
10:03
various properties and scroll down and
10:06
get the information that you need so
10:09
what we need to do is we need to set
10:11
that initial capital and we also need to
10:13
be able to set up Margin calls because
10:15
we can't just leverage without any
10:17
margin calls and understand how much
10:19
Equity that we're going to use now I
10:21
already understand this information so
10:23
I'm not going to waste your time here
10:24
but we'll just run through one because I
10:27
want you to get comfortable with this so
10:28
we'll go and look at the margin long
10:30
property here it is and it says margin
10:33
long is a percentage of the purchase
10:35
price of a security that must be covered
10:37
by cash or collateral for long positions
10:39
must be a non-negative number right that
10:42
makes sense and it's used to simulate
10:44
margin calls and explained in The Help
10:46
Center so you can click on that if you
10:48
want more information but let's go ahead
10:50
and now set the initial Capital the
10:52
Margin Call and the amount of capital
10:54
used
10:55
so take initial Capital I'll copy this
10:59
and this is getting pretty long so I'm
11:01
going to press comma hit enter tab space
11:05
paste the initial Capital we want a
11:07
thousand we also want the default
11:10
quantity value to be a hundred and then
11:13
we also want margin long
11:18
now obviously we've got some exchanges
11:20
that offer 1 to 100 leverage we'll just
11:22
do one to ten and then what we'll do is
11:24
we'll save this and we'll see how this
11:27
adjusted our strategy we'll open the
11:29
strategy tester and we'll see that
11:31
overview looks like we've already taken
11:33
a thousand dollars in capital to over
11:36
2.3 million so if we met our goal I
11:39
don't want to stop here I don't know
11:40
about you there's a lot more that I want
11:42
to talk about so we'll change the 1000
11:45
to 1 million dollar trading strategy to
11:47
the 1 000 to 10 million dollar Bitcoin
11:51
trading strategy now how can we improve
11:54
upon this strategy well if I look here
11:56
when we're looking at this Equity curve
11:58
it's going up and then we start to see
12:00
some downward movement here if I click
12:03
on this we can see here that Bitcoin I'm
12:06
going to zoom out a little bit we can
12:08
see that we're in a pretty good uptrend
12:10
and it looks like we're you know we're
12:12
also losing money on this this downtrend
12:15
here so there's two things that I want
12:17
to resolve the first is we want to not
12:21
be in Bitcoin when it's over extended
12:24
and secondly when the trend is down we
12:29
want to exit right so let's go ahead and
12:31
use chat sheet PT our friendly research
12:34
assistant to figure out how we might be
12:36
able to do that now it seems like chat
12:38
gbt is experiencing some exceptionally
12:40
high demand let's hope it gives us the
12:42
answer we're looking for anyways we will
12:45
ask for quick answers and we'll say give
12:47
me a list without descriptions
12:51
of technical indicators that are
12:54
excellent
12:55
or identifying
12:59
over extended prices
13:02
hopefully it'll give us a few all right
13:03
so RSI stochastic oscillator Williams
13:06
Bollinger Bands perfect we'll use the
13:08
RSI and our strategy to identify
13:10
overextended prices so what I'll do is
13:12
I'm going to go up here and edit this
13:15
and say give me a list without
13:16
descriptions of technical indicators
13:19
that are excellent for identifying
13:23
when a market is trending
13:27
and click save and submit and we'll see
13:29
what happens moving average RSI
13:30
Bollinger Bands macd parabolic SAR
13:33
Fibonacci retracement all of these okay
13:36
we've got the adx so what we'll do is
13:38
we'll use the RSI to identify over
13:41
extended prices and we'll also use the
13:43
adx to determine whether or not we're
13:46
ranging or trending and fit that into
13:48
our strategy to see if we can get up to
13:51
that or maybe even surpass that 10
13:53
million dollar mark we'll start by
13:55
adding the RSI and potentially get us
13:57
out of overextended Trades we see that
14:00
the RSI is already charted up here and
14:02
we can be absolute maniacs and click on
14:04
the source code here copy all this and
14:06
paste it into our Pine script or ask
14:08
Chachi BT to massage this code into our
14:11
existing strategy but that is way way
14:12
way too difficult there's a much better
14:14
method let's open up our previous
14:16
strategy we'll click open you can use
14:19
either the recently used or go to my
14:21
script here I see the super Trend
14:23
Bitcoin strategy I'm going to click on
14:25
that and remember I said you can access
14:27
everything that you need to access by
14:29
control clicking on any keyword which is
14:32
highlighted in blue essentially it'll
14:34
pull up the pine script reference manual
14:35
if for some reason you don't want to
14:37
access it that way you can always click
14:39
this triple Dots here and click the pine
14:42
script reference pop-up now I want to
14:44
know about the RSI so I'll just type in
14:46
RSI we see it as the first result which
14:49
is already being displayed and it tells
14:52
you everything that you need to know
14:53
about the RSI if you have questions you
14:56
can literally copy and paste this in the
14:58
chat GPT and explain it to you I'm going
15:01
to copy this code right here we'll use
15:04
the close as the source and the length
15:06
you know we'll use probably a little bit
15:08
longer because I want to try to capture
15:10
you know make sure that there's room to
15:12
run so what we'll do now is we'll scroll
15:14
down to where we enter
15:17
now we could ask Chachi PT to do this
15:19
for us but it is having some bandwidth
15:21
issues at the moment and you really
15:22
should get into the habit of being able
15:24
to read basic Pine script we'll say and
15:27
right so it has to have this direction
15:29
change and I'll paste this to TA dot RSI
15:33
close price and the is the value we're
15:37
going to calculate this off to close and
15:39
we'll say you know what 21 is less than
15:43
66. so we're saying that you know we
15:45
don't want to be overbought on a longer
15:48
term time frame but you know what I also
15:50
want to make sure that we're getting in
15:52
to the trade whenever there's a very
15:56
high RSI on the shorter time frame which
15:58
will essentially sort of mimic a
15:59
breakout and some serious buying
16:01
pressure we'll say close 3 is greater
16:05
than 80. now what I'm going to do is I'm
16:06
going to save this then we'll check the
16:08
results and we'll see if this solved the
16:11
issue with getting into and you know
16:14
getting out of I should say overextended
16:16
trades and then we'll see how we can
16:17
prove this strategy likely using the adx
16:20
to determine you know that downtrend and
16:22
getting out of that so I'm going to save
16:23
now and check out the results so go to
16:26
the strategy tester we see our overview
16:28
and it looks like we've made some
16:30
progress but I'm starting to get a
16:32
little nervous right so we're at three
16:34
million in profits we're not at 10
16:36
million plus yet I don't know if I'm
16:38
going to be able to get get us there but
16:40
I'm going to try my hardest we can see
16:42
that the equity curve is you know
16:44
fantastic and then all of a sudden we
16:46
have this drop off so click on this
16:47
again just to analyze it one more time
16:49
you know it looks like uh you know this
16:52
downtrend is really eating us up and
16:54
also this sideways action right so we'll
16:56
use RSI to try to negate some of this
17:00
downward pressure and then also use the
17:02
adx to make sure that we're trending and
17:04
not uh you know getting chopped up so
17:07
the way we'll do that is we'll go back
17:08
to the Pine editor and now the 80 well
17:11
let's first start off with the RSI
17:13
that's easy to do what we'll do is we'll
17:15
just add a longer RSI duration and say
17:18
that we have to be above you know 49
17:20
meaning that there's some buying
17:22
pressure and we're not constantly having
17:23
lots of cell pressure so we'll say ta
17:26
oops and ta dot RSI
17:29
use the close price we'll say
17:33
close we'll say 28 you know four weeks
17:35
is greater than 49 and then what we'll
17:38
also do is we're going to actually we'll
17:41
save that you know we'll save that now
17:43
and we'll check out our results and see
17:45
what happens here to see if we get rid
17:47
of some of that downward action and then
17:49
we'll handle the chop
17:51
click on the strategy tester and oh man
17:54
we're so close we went from you know
17:56
three million and change to 5.3 we're
17:58
now at a two-thirds win percentage and
18:01
we've still got a little bit of room for
18:03
improvement hopefully that'll get us
18:04
over that 10 million dollar Mark we can
18:06
go to the Pine editor uh click on
18:09
control click on any one of these
18:10
keywords so we can use input if we want
18:12
and you'll notice it just pulls up input
18:14
so whatever we're control clicking on
18:16
it'll pull up and then we're going to
18:17
type in adx
18:19
and you'll notice that unlike the RSI we
18:21
don't see it so what we'll do is we'll
18:23
go to the indicators metrics and
18:26
strategy to click on this go to
18:28
technicals and then we'll search for the
18:30
adx and you'll see here when we click on
18:33
average directional index adx it'll come
18:35
up on our charts we can click on the
18:37
source code and now what we'll do is
18:39
we'll copy all of this we don't need
18:42
indicator we'll just copy this you only
18:45
need one indicator or strategy and then
18:47
we'll go back to our original strategy
18:51
which is the super Trend Bitcoin
18:53
indicator I'm going to paste it you can
18:55
paste it pretty much anywhere above you
18:58
know where we're going to use it here
18:59
I'm going to paste it in here I don't
19:02
want to plot it
19:04
we can ask chat GPT and maybe we will
19:06
after this if we don't get it the whole
19:09
way what exactly this code is doing but
19:11
I know that the Sig is the signal and
19:15
you know we want it to be relatively
19:17
trending so we'll say and Sig is greater
19:20
than 30. and hit save and we'll see if
19:24
we get it there
19:25
come on baby oh no we went from millions
19:30
and millions to 62 000 yeah uh I guess
19:33
what are we gonna do now all right well
19:34
I think obviously that adx really messed
19:37
us up but maybe we should ask Chachi PT
19:40
how we can make it better right so we'll
19:42
say chat GPT how can we make the adx
19:48
more responsive right so clearly it took
19:52
us out of too many trades now I know
19:54
that you know and you can ask Chachi PT
19:57
this come on I know that you're you're
19:59
you're getting hit with all sorts of
20:00
requests but this is really important uh
20:03
give us an answer I know that uh the adx
20:06
strong trend is above 30 and a weak
20:08
Trend typically is above 20. so we'll
20:10
make it more lenient and we'll also do
20:13
what Chachi BT tells us to we'll shorten
20:16
the period uh and uh you know make it
20:19
more responsive and hopefully hopefully
20:21
that'll get us there so we'll go to the
20:22
Pine editor we'll go first down to to
20:26
the signal here will make it 20 to give
20:28
us you know to get us into more trades
20:31
and then we'll change this input length
20:34
how about we just cut it in half
20:36
and I'll click save and cross our
20:40
fingers because there's not much more
20:42
left in this YouTube video
20:44
come on come on oh we're 6.5 million
20:49
we're so close
20:50
all right one one final thing we'll see
20:53
uh we'll see what happens here let's
20:55
change this you know percent that we're
20:57
betting to 120. we'll hit save and I
21:00
think this is it guys let's see if that
21:03
last ditch effort worked and yes it did
21:05
we're in 17.4 million dollars not only
21:08
did we beat our initial goal of taking 1
21:11
000 to over a million dollars we then
21:13
had a stretch goal of taking a thousand
21:15
over to 10 million dollars let me
21:17
crushed that it's 17.4 million dollars
21:20
this is a fantastic video in what's
21:22
called over optimization and you can use
21:24
chat GPT to look that up if you have if
21:27
you're not sure what that means but this
21:28
video is about two Super Key takeaways
21:31
first Chachi PT is here to stay you need
21:34
to use these tools otherwise you're
21:36
going to fall behind you can be a no
21:39
programmer or a novice programmer and
21:42
actually back test strategies now you
21:44
don't have to just listen to someone on
21:46
Twitter and hope and pray that that
21:48
works right that's what my blog is about
21:50
analyzing Alpha is about finding these
21:53
amazing Traders and investors that are
21:55
somehow kicking the crap out of the
21:57
markets and determining how they
21:59
actually did that and now you are
22:01
empowered to be able to do this yourself
22:03
so this is fantastic and secondly for
22:06
experienced Traders it's amazing you
22:08
have all of this wealth of knowledge at
22:10
your fingertips so hopefully this video
22:12
was worthwhile to you I think it was a
22:15
17.472 million dollar knowledge bomb
22:17
everyone should be using chat GPT in
22:20
some way and both in their personal
22:22
lives in their trading and I hope to see
22:24
you in the next one thanks goodbye
#Investing
#Commodities & Futures Trading
#Brokerages & Day Trading
