CODING TRADING AUTOMATIONS | July 24 | Michele Rossi — Transcript
Full transcript
- 0:00Here
- 0:02we are again. Welcome back, beautiful
- 0:06people. If you can hear me or see me,
- 0:09leave a comment in the chat. Say hello
- 0:11and subscribe to the channel. Thank you
- 0:13so much, Fun Pro, for having me. This is
- 0:16the second lesson we're going to have
- 0:19about
- 0:21creating a strategy
- 0:24from the idea to the final
- 0:29functional
- 0:31strategy and bot to deploy on a prop
- 0:35firm. So in the last lesson we talked
- 0:39about everything about on how to create
- 0:43a strategy. We talked about
- 0:47technicals let's say I mean just we wrap
- 0:51around our head around the idea on why
- 0:55is it a good idea to code the strategy
- 0:58um and why
- 1:00is a good idea to use automation build
- 1:05your own strategy back test the strategy
- 1:08and then deploy it live on your prop
- 1:11firm uh today we're gonna
- 1:14have the first step and we're going to
- 1:16start to put our hands in the mud and
- 1:19start creating something. Today we start
- 1:22from the idea. Um, so we're going to go
- 1:27from the idea to the first working
- 1:30version today. So be careful, listen
- 1:34carefully, take some notes and if you
- 1:37want you will find this video recorded
- 1:41on YouTube on the YouTube channel of
- 1:43funprog.
- 2:02Trading.
- 2:18So, welcome to the first chapter of this
- 2:21week. Today, we're going to build the
- 2:23first working version of a trading
- 2:25strategy.
- 2:27um not just look at the chart and say
- 2:29this could work. We are going to start
- 2:32with a market idea. Turn that idea into
- 2:37precise rules and give those rule to
- 2:40codeex. We're going to use chat GPT you
- 2:42can use codeex you can use cloud code
- 2:46whatever it works best for you and we're
- 2:49going to use it to generate a pine
- 2:51script strategy. I know this is not the
- 2:56institutional way to do stuff but
- 3:01we're working on proper okay we're not
- 3:06competing against institutions that's
- 3:10not our job we are working into a
- 3:14virtual environment
- 3:17we're just looking at the real market
- 3:19we're not actually intervene
- 3:22in the real market. So, we're going to
- 3:25go deep on this um statement later on,
- 3:31but for now, so we're going to code the
- 3:35strategy with CHBT. We're going to have
- 3:38a Pine Script strategy. We're going to
- 3:40add it to Trading View. We're going to
- 3:43inspect the results and find the first
- 3:46problems and correct them. So by the end
- 3:49of this lesson, we will have a real
- 3:52baseline version of our strategy.
- 3:55It may be not profitable. It may not be
- 4:00robust. It will certainly not be ready
- 4:04to deploy yet, but it will be something
- 4:08that we can test, that we can measure
- 4:12and improve. And this is the first
- 4:15important step because you cannot
- 4:17properly validate an idea that has never
- 4:21been defined before. You cannot optimize
- 4:25rules that keep changing
- 4:28and you should never deploy a strategy
- 4:31that exists only as a bug concept in
- 4:36your head. [snorts] Over the next four
- 4:39lessons, we will follow the complete
- 4:42process. Today we move from the idea to
- 4:45the first functioning version. In the
- 4:48next lessons we will validate the
- 4:50strategy using trading view data. We
- 4:53will collect the complete list of trades
- 4:55and give that data to codeex. We will
- 4:58ask Codex to analyze the results and
- 5:00identify weaknesses, test different
- 5:03assumptions and help us investigate
- 5:06whether the strategy has a real edge or
- 5:08whether the historical results is simply
- 5:12the product of overfeeding.
- 5:16Again, we're not using
- 5:19all the indepth level three data. Of
- 5:24course, we're using a um an entrylevel
- 5:29data which is trading view. They have
- 5:33few tick datas, not even the full
- 5:35history, but it's more than enough for
- 5:38us to start
- 5:40understand the concept on how to code a
- 5:43strategy,
- 5:45back test the strategy automatically,
- 5:47um optimize it, validate it and deploy.
- 5:51And you are going to be surprised on how
- 5:56much this could potentially be really
- 6:00really profitable.
- 6:02Okay,
- 6:04we will also look at a Monte Carlo
- 6:06testing in sample and out of sample
- 6:09testing and cross validation. Finally,
- 6:13once we have a version that has survived
- 6:16the validation process, we will discuss
- 6:19deployment. At that point, we could
- 6:22convert the strategy into, if you wish,
- 6:24MQL5 for MetaTrader 5 or Ninja Trader
- 6:29with Python or C++ or we could leave the
- 6:32strategy on Trading View and use an
- 6:35external bridge to copy the signal to
- 6:37the account we choose. For this project,
- 6:40we are going to keep the strategy on
- 6:41Trading View. But first, we need to
- 6:43build it correctly.
- 6:46All right, let's start and let's begin
- 6:49with the idea. The strategy we are going
- 6:53to use is the orb is the most discussed
- 6:58and talked strategy of the last couple
- 7:01of years, but it's running around
- 7:07since the 80s, since the 70s,
- 7:121970s, 1980s.
- 7:14I don't know. But it's it exists from a
- 7:17long time. And you might think
- 7:21okay if it exists
- 7:24for this very long time maybe we got
- 7:28alpha decay the strategy is no more
- 7:30profitable. No that's not the case
- 7:33because we're not talking about a
- 7:36precise set of rule. We're talking about
- 7:40the overall concept which is the opening
- 7:44range breakout around that we can build
- 7:48multiple layers of filters not too much
- 7:51to avoid overfeitting
- 7:54to find a little small new edge that we
- 7:59can use if it exists to pass the
- 8:03challenges and to make payouts. That's
- 8:05the idea and I've already done that. so
- 8:09many times. My students have already
- 8:11done that so many times. So can you.
- 8:16So the OB stands for opening range
- 8:20breakout. The name sounds complicated
- 8:23but the basic idea is very simple. At
- 8:25the beginning of a trading session, we
- 8:28are going to
- 8:31define a range.
- 8:34Right? [snorts]
- 8:36For example, we can use the first 15
- 8:39minutes after the New York market opens.
- 8:44So, if you're in Italy, as I was for the
- 8:49last 40 years,
- 8:52the opening range is going to be between
- 8:553:30 to 3:45
- 9:00p.m.
- 9:04GMT + 2. Okay, this is the New York
- 9:08Stock Exchange opening first
- 9:1415 minutes,
- 9:16right? This is the opening range and
- 9:19you're going to have such a candle
- 9:24with a it's
- 9:28high low opening and close. Let's say
- 9:32it's like this of HCL.
- 9:39This is the low. This is the high. This
- 9:41is the opening. And this is the closing
- 9:44of the candle. Right at the end of these
- 9:49of the 15minut period, we have two
- 9:52important level.
- 9:55The high of the opening range and the
- 9:58low of the opening range. After that we
- 10:01wait. If price
- 10:05is going to
- 10:07closes above the opening range high, we
- 10:11look for a long trade.
- 10:16If price closes below
- 10:21the opening range, we're going to short
- 10:25[snorts] and sell
- 10:28the price.
- 10:30That is the basic ORB concept, the orb.
- 10:35But now we need to ask the question that
- 10:37should always come before writing code.
- 10:41Why should this idea work?
- 10:46Why would the first 15 minutes of a
- 10:49trading session be important?
- 10:52The reason is that the market does not
- 10:54behave exactly the same way throughout
- 10:57the day. When an important session
- 11:00opens, activity often increases.
- 11:05There may have been news during the
- 11:07night. There may be orders waiting to be
- 11:11executed. There may be a difference
- 11:14between the price accepted during the
- 11:16overnight trading and the price accepted
- 11:20when the main market opens.
- 11:23uh buyers and sellers begin to interact
- 11:26more aggressively.
- 11:30So the first few minutes can therefore
- 11:34create a kind of initial balance.
- 11:38The high range tell us where buyers
- 11:42stopped the market during that initial
- 11:45period. The low tells us where sellers
- 11:48stopped it. If price later breaks
- 11:52through one of those levels, the
- 11:55breakout may show that one side is
- 11:57becoming more aggressive.
- 12:01A close above the range may suggest that
- 12:04buyers are willing to continue paying
- 12:07higher prices.
- 12:09A close below the range may suggest the
- 12:12sellers are willing to continue
- 12:13accepting lower prices. That is
- 12:18that is the market hypothesis
- 12:22and I want to be precise about the word
- 12:24hypothesis. We are not saying that orb
- 12:28works. We are not saying that every
- 12:30breakout continues. We are not saying
- 12:33that the strategy
- 12:35has an edge simply because the idea
- 12:38sounds logical. We are saying that the
- 12:42behavioral
- 12:45the behavior is specific enough to
- 12:47investigate.
- 12:50That is the difference between an idea
- 12:52and the conclusion. An idea says maybe
- 12:56the opening range contains useful
- 12:59information about the next part of the
- 13:01session.
- 13:03A conclusion say the historical data
- 13:06shows that the behavior creates a
- 13:08repeatable advantage after realistic
- 13:11costs. We are not at the conclusion yet.
- 13:14We just started today. We are only
- 13:16building the system that will allow us
- 13:19to investigate the idea properly.
- 13:23Let me show you how this can look on a
- 13:26real chart. Okay,
- 13:29let me clean up the chart.
- 13:34>> [snorts]
- 13:36>> So for this example, I'm going to use uh
- 13:40the the a 15minute range. Let me go
- 13:43back. I I'm going to cherrypicking the
- 13:46idea. So it's going to be
- 13:49useful and clear for you.
- 13:53There it is. Let me go back. Let me find
- 13:58some good or example. This can be one.
- 14:01There it goes.
- 14:04[snorts] Beautiful.
- 14:06I know it's cherrypicked, but this is
- 14:08educational, okay? I'm not going to
- 14:10cherrypick anything else, but I need to
- 14:13show you how the process work. So, I'm
- 14:16going to use a 15inut opening range on
- 14:19the New York session. There it is. Is it
- 14:243:30? The market open [snorts]
- 14:27right here.
- 14:34So this is the first five minute candle.
- 14:37This one right here. 5 minute 5 minute 5
- 14:41minute. We have our 15 minute range.
- 14:48Right.
- 14:50We're gonna have the orb
- 14:53opening range high
- 14:57and we're gonna have we already have
- 15:01actually our open range low.
- 15:09The market and the exact ticker are
- 15:14important. If you use one trading view
- 15:17symbol and then you use another, we may
- 15:20not get the same prices, the same spread
- 15:22or the same session data. So I'm going
- 15:24to use the exact symbol visible here.
- 15:28Okay, I'm using the micro MQ micro E
- 15:33mini NASDAQ 100 index futures of CME.
- 15:39Right? So you can do the same.
- 15:42Um
- 15:44now
- 15:49the session begin here
- 15:54for the first 15 minutes. I'm not
- 15:56interested in taking any trades. One,
- 16:00two, three, 15 minutes. One, two, three,
- 16:03five, 10, 15. [snorts] I'm only
- 16:06measuring the market. During this
- 16:10period, the range
- 16:12is being created.
- 16:18This candle reaches the
- 16:22the high the highest price of the
- 16:24opening window. This candle reaches the
- 16:27lowest price. So at the end of the
- 16:29opening period, these two levels become
- 16:33our first range high and range low. From
- 16:37this point forward, the range should
- 16:39remain fixed. Now look at what happens
- 16:42next. Price move above the range high.
- 16:51There it goes. And we have a closure.
- 16:54There it is. Let me go back one candle.
- 16:58There it is. Our opening range high.
- 17:02Sorry, I already have my
- 17:05some of my bots installed here.
- 17:08So, this is the first trigger candle.
- 17:14That is the type of event we are going
- 17:16to code.
- 17:18The important detail is that the entry
- 17:21is based on the close,
- 17:24not simply on a week. So if we had a
- 17:28previous candle that wicked and closed
- 17:30back inside of the range, that is not an
- 17:32entry.
- 17:35This is one of the decisions that makes
- 17:38the strategy precise. If you we don't
- 17:42define this, someone else could
- 17:43implement an intraar entry and get
- 17:46completely different results. Now let's
- 17:50use this number. We're going to have our
- 17:53entry right here.
- 17:57We're going to have a our stop loss.
- 18:01Let's figure out we're going to put it
- 18:03on the opposite range. So on the or low
- 18:10and we're going to target a one to two
- 18:14risk to reward.
- 18:16We're risking one to target two. We're
- 18:20risking 1% to make it 2%.
- 18:28And we have to be very careful and
- 18:31precise on what we are going to say to
- 18:37define our strategy. So the rules at the
- 18:41moment are very simple. Wait for the
- 18:45first 15minut candle. Mark up the high
- 18:49and the low of the range and wait for a
- 18:51candle of five minute closing above or
- 18:55below. We have our candle closing above.
- 18:58Right at the close, we open a buy
- 19:04order. We're going to put our stop loss
- 19:07on the opposite range on the or low and
- 19:10we're going to target a one to two
- 19:12risk-to-reward.
- 19:14These are the rule of the strategy.
- 19:17Okay. [snorts]
- 19:20Um, of course, we also have to
- 19:26uh ask ourself some follow-up question.
- 19:31Are we going to enter on the same candle
- 19:33or on the next bar? Are we including
- 19:35commission? Are we including slippage?
- 19:37What happens if the breakout occurs five
- 19:40minutes before the session closes? What
- 19:42happens if price breaks both sides of
- 19:45the range? These are not secondary
- 19:48question. Those are very important
- 19:50question. We're going to ask these
- 19:51questions a little bit later. And this
- 19:54is also why most strategies found on the
- 19:57internet are not immediately useful.
- 20:00Often they are presented as a visual
- 20:03ideas rather than a complete system.
- 20:06Someone shows us a chart and say by the
- 20:08breakout. But which breakout? The first
- 20:12breakout of the day, the breakout after
- 20:14a pullback, a breakout confirmed by
- 20:17volume, a breakout that closes above the
- 20:21level, and what happens after the
- 20:24entitle, when is the stop-loss, when is
- 20:27the target, when do we stop trading? If
- 20:30these questions are unanswered, the
- 20:33strategy cannot be reproduced. Another
- 20:36problem is that we usually see only the
- 20:39best examples like we're doing right
- 20:41now, but for educational purposes. We
- 20:44see three winning trades on a shorts on
- 20:47Tik Tok or Instagram, but we do not see
- 20:50the losing trades.
- 20:53[snorts]
- 20:53We do not know whether the performance
- 20:56includes commissions and slippage and
- 21:00perhaps spreads. If you are on CFD
- 21:02especially,
- 21:04we do not know if the strategy is using
- 21:07future information and sometimes the
- 21:10strategy has been optimized so many
- 21:12times that it works only because it has
- 21:14been fitted to one particular historical
- 21:18period. A real edge is not a magical
- 21:21indicator
- 21:22uh is not a win rate is not a beautiful
- 21:24equity curve in edge is a repeatable
- 21:28statistical advantage. A strategy can
- 21:31win 40% of its trades and still be
- 21:34profitable if its winning trades are
- 21:38sufficiently larger than its losing
- 21:41trades. A strategy can win 80% of its
- 21:44trades and still lose money if the
- 21:46occasional losses are too large. So we
- 21:50need to study the complete distribution
- 21:53of results. We need to look at average
- 21:56trade, profit factor, draw down, losing
- 21:59streak, and performance across different
- 22:01periods. But before any of that, we need
- 22:04a strategy that is stable enough to
- 22:07test.
- 22:09Now, I'm going to write the technical
- 22:13specification.
- 22:15I'm doing this before asking Codex to
- 22:18write the code. We're doing together.
- 22:20Don't worry. This is important. Codeex
- 22:23can write pine script very quickly as
- 22:25well as
- 22:27uh cloud code or any other AI but it
- 22:31cannot read my mind. If I give it a v
- 22:34idea it must make assumptions and if
- 22:37those assumptions remain hidden I may
- 22:41end up testing rules that I never
- 22:43intended to create. So, I'm going to
- 22:46write the specification
- 22:48directly here so you can see and you can
- 22:51try and do the same. I don't like the
- 22:54red. Let me use blue. No, it's not
- 22:57visible. Let me use yellow. Let's go
- 23:00with the yellow.
- 23:03There it goes. So,
- 23:07the first part is the market. I will
- 23:09write we are using
- 23:13>> [snorts]
- 23:14>> uh the selected
- 23:18trading view symbol.
- 23:22Right? This is the first thing we have
- 23:24to say codeex. What symbol are we using
- 23:28at the moment?
- 23:31Right? MNQ. So we're going to use
- 23:35MNQ, right?
- 23:39But of course we can use the same we
- 23:42want to be able to use the strategy on
- 23:45different chart and test it on different
- 23:47scenario. Maybe you want to use it on YM
- 23:50which is the Dow Jones. You might want
- 23:52to use it on ES which is the S&P 500. So
- 23:55we are using
- 23:59the selected trading view symbol means
- 24:02that whatever symbol we are using the
- 24:05strategy whatever chart we are using the
- 24:07strategy on trading view is going to uh
- 24:13test the strategy on that symbol. The
- 24:15ticker
- 24:17must not
- 24:19be hard
- 24:23coded.
- 24:26This mean the script should work with
- 24:27the symbol displayed on the chart. This
- 24:29is simple. The second part is the
- 24:32session.
- 24:34The strategy
- 24:37uses the New York
- 24:41um
- 24:44session
- 24:45and the
- 24:49America
- 24:52New
- 24:54York time.
- 24:59Sorry, let me go
- 25:03time zone. Right. You can use the
- 25:09Italy time zone. You can use the India
- 25:13time zone. You can use Japan time zone.
- 25:17But we're going to use the New York
- 25:18session. We're going to trade in the New
- 25:20York session. I'm deliberately
- 25:24specifying the time zone. I do not want
- 25:27the strategy to use the time zone of my
- 25:29computer or whatever time zone happens
- 25:33to be selected on the chart. The third
- 25:35part is the opening range. This is also
- 25:38very important for [snorts] Metatrader,
- 25:41but we're going to talk in another time.
- 25:43The range begin at 9:30 a.m.
- 26:01New York time
- 26:04and ends
- 26:08[snorts]
- 26:08at 9:45
- 26:12a.m.
- 26:17During
- 26:20the those
- 26:2315 minutes,
- 26:25the strategy
- 26:28records
- 26:30the highest
- 26:33and the lowest
- 26:37low.
- 26:39So, the highest high
- 26:42and the lowest low.
- 26:46No trade
- 26:48is allowed
- 26:52while
- 26:54the range is forming.
- 27:00Once the range is complete,
- 27:06the levels
- 27:09are fixed.
- 27:15Okay. Now the fourth part is the entry,
- 27:20right? We need to tell when to enter
- 27:22long and when to enter short. So,
- 27:28a long signal
- 27:31occurs
- 27:34only when a confirmed candle
- 27:41[snorts]
- 27:42closes
- 27:47above
- 27:50the range high.
- 27:54While for a short
- 27:57[snorts]
- 28:01signal, a short signal occur only when a
- 28:05confirmed candle closes below the range
- 28:10low. Right? [snorts]
- 28:14only one entry
- 28:23um is allowed per
- 28:27session.
- 28:32If the first trade, let me dictate. So,
- 28:34I'm going to go faster. If the first
- 28:36trade is long,
- 28:40we do not later open a short trade on
- 28:43the same day.
- 28:45Oh, it's not working. Let me write it
- 28:47down. If the first
- 28:53trade is long,
- 28:57[snorts]
- 28:59we
- 29:01do not later open a short trade
- 29:09on the same day.
- 29:17Same apply
- 29:20for the short. If the first trade is
- 29:24short, we do not later open a long
- 29:27trade [snorts] on the same day just to
- 29:30be sure
- 29:32we're hardcoding every property,
- 29:37every rule, every idea,
- 29:41everything that can mess up with the
- 29:43with the logic of the strategy.
- 29:47So the sixth part is the stop for a long
- 29:51trade.
- 29:57Let me see if we can do this right. We
- 30:00can do this. I can dictate now. Okay.
- 30:04For a long trade, the stop goes at the
- 30:07opening range low. It works.
- 30:12For a short trade, the stop goes at the
- 30:16opening range high.
- 30:18Right?
- 30:20Then let me stop the right. Then the
- 30:24seventh part is the target.
- 30:28So what are we going to say
- 30:31is
- 30:33we use a configurable risk-to-reward
- 30:37ratio with a default value of two.
- 30:41Perfect. Wisher pearl is crazy good.
- 30:47I need to remember to stop and restart.
- 30:52Then the target must be calculated from
- 30:57the actual entry price and the initial
- 31:00stop distance.
- 31:02Right?
- 31:05Then the eighth part is the session
- 31:07exit.
- 31:11Any open position is closed at the end
- 31:14of the session. There is no overnight
- 31:17holding
- 31:20this.
- 31:22Let me go a little bit smaller.
- 31:29And the ninth part is position size. For
- 31:33the first version, we will use a
- 31:35configurable quantity. We are not trying
- 31:37to solve the entire portfolio risk
- 31:39management problem here.
- 31:47There it goes.
- 31:50[snorts]
- 31:51Um, so
- 31:53we are trying to create a clean
- 31:55baseline.
- 31:57The final part is the visual behavior.
- 32:00So we need to tell the script to show
- 32:03because we want to see we we can we can
- 32:05do it. So we we can we want to also be
- 32:08able to see the script must show the
- 32:11range high and low. It must shade the
- 32:14opening range area. It must mark
- 32:17entries. It must show the active stop
- 32:21and target. That way we can compare what
- 32:24the code does with what the rule say it
- 32:28should do.
- 32:34Come on. Whisper plot, please don't
- 32:37abandon me. There it goes. So, this is
- 32:41our complete first specification. It is
- 32:44simple but is precise. Now, I'm going to
- 32:47turn that specification into the prompt
- 32:50I will use with codeex. I want to show
- 32:53you the exact process because the prompt
- 32:55is part of the development workflow. I'm
- 32:58not going to describe the prompt
- 33:00afterwards. I'm going to write it, sand
- 33:03it, and use the results. Okay,
- 33:07so I already have this prepared. I'm
- 33:10going to copy and paste it inside of
- 33:15Codeex.
- 33:17So, let me open up Codeex.
- 33:26There it is.
- 33:34There it goes.
- 33:37Right.
- 33:39I'm going to use 5.6 salt or whatever
- 33:43you have. I'm going to paste this whole
- 33:45code. Let me write it to you. Let me
- 33:48read it to you guys. Okay. So, it's very
- 33:53simple and you can copy paste. You are
- 33:56an experienced Pine script developer and
- 34:00systematic trading researcher. Create a
- 34:03trading view strategy in Pine version
- 34:05six based on the following
- 34:07specification.
- 34:09And these are the specification.
- 34:12Use the trading view symbol selected by
- 34:14the user. Do not hardcode a ticker. Do
- 34:16use American New York at the session
- 34:18time zone. Do not use the computer's
- 34:20local time zone or the charts time zone.
- 34:23The trading session begins at 9:30 New
- 34:25York time. The opening range lasts for
- 34:2715 minutes and end 9:45 New York time.
- 34:30During the opening range, record the
- 34:32highest high. Record the highest low. Do
- 34:34not open any trade. After the opening
- 34:36range is complete, enter long only after
- 34:39a confirmed candle closes above the
- 34:42opening range high. Enter short only
- 34:44after a confirmed candle closes below
- 34:46the opening range low. Allow only one
- 34:49entry per session. Do not reverse the
- 34:52position during the same session. For a
- 34:55long trade, place the stop- loss at the
- 34:56opening range low. Calculate the profit
- 34:58target using a configurable
- 35:00risk-to-reward ratio. For a short trade,
- 35:03place the stop- loss at opening range
- 35:05high. Calculate the profit target using
- 35:08the same configurable risk-to-reward
- 35:10ratio. Use a default risk-to-reward
- 35:12ratio of 2.0. Close any open position at
- 35:16the session end. Do not hold positions
- 35:18overnight. Create inputs for sessions
- 35:20serve time, sessions and time, opening
- 35:22range duration, riskto-reward ratio,
- 35:24position size, commission, sleepage,
- 35:28visual requirement. Plot the opening
- 35:31range high and low, shady opening range
- 35:33area. Plot the active stop-loss and
- 35:35target. Mark long and short entries.
- 35:38Include an optional debug mode.
- 35:40Technical requirements. Use confirm bar
- 35:43data. Avoid look ahead bias. Reset all
- 35:47daily and session variables correctly.
- 35:50Make the code readable. Add commands
- 35:53explaining the session logic and trade
- 35:56logic. Include alerts for long entries,
- 35:59short entries, stop losses, target, and
- 36:02sessions close.
- 36:05Before providing the coin the code,
- 36:08explain the main assumption and
- 36:11execution model. then provide the
- 36:13complete fine script.
- 36:16Right? Here we go. So this is it.
- 36:23Is that everything clear?
- 36:26Do you guys have any questions about it?
- 36:30Please let me know in the chat.
- 36:39Beautiful.
- 36:41Beautiful,
- 36:52right? Okay, cool. Let's send it to
- 36:55codeex
- 36:57and wait.
- 37:03So while the code is being generated
- 37:08by codeex notice what we are doing we
- 37:13are not asking codeex to find a
- 37:15profitable strategy. We are not asking
- 37:18it to optimize the parameters. We are
- 37:20not asking it to add indicators until
- 37:23the equity curve looks good. We are
- 37:26asking it to implement a clearly defined
- 37:31hypothesis.
- 37:33That distinction is extremely important.
- 37:37If we ask codeex to make the strategy
- 37:40profitable, it may change the rules and
- 37:44filters or optimize parameters before we
- 37:48even understand the baseline.
- 37:51So for now, we need a faithful
- 37:54implementation,
- 37:55right? We need to wait. It's going to
- 37:57take
- 37:59a little bit of time. So, if you have
- 38:02questions, this is a very good moment to
- 38:04ask
- 38:10or we're just going to wait.
- 38:15[snorts]
- 38:27assumptions and execution models.
- 38:31Right here it comes.
- 38:34Coded codex is writing the code
- 38:40based on my hypothesis.
- 38:50It's going to be ready very soon and
- 38:53we're going to test it in the chart.
- 39:00If you want the full code,
- 39:03I mean the prompt to generate the code,
- 39:08just follow me on Instagram official and
- 39:11ask or you follow and subscribe to my
- 39:14YouTube channel and you command by
- 39:18asking.
- 39:22that
- 39:34there it is. It's ready. It didn't take
- 39:37more than five minutes. Right now
- 39:41before copying it into trading view I'm
- 39:46going to ask codeex to explain the most
- 39:50important parts.
- 39:53So
- 39:55I'm going to ask this very prompt.
- 40:00I'm going to ask this.
- 40:03Review the script you just created. Do
- 40:06not rewrite the code yet. Explain how
- 40:09the session is detected, how the opening
- 40:11range begins and ends, how the high and
- 40:14lows are stored, etc., etc., etc., etc.
- 40:17Identify any possible bug or ambiguity.
- 40:21Right? This review is very useful
- 40:27because it forces us to understand the
- 40:30code before trusting it. So if codeex
- 40:35says that the range is being calculated
- 40:37using future bars we know there is a
- 40:40problem. If it says the that entries are
- 40:44generated
- 40:46intraar that does not match our
- 40:48specification. If it says that the
- 40:51strategy can reopen a trade after the
- 40:53first one closes we know the sessions
- 40:55lock is incomplete. The explanation is
- 40:59not a substitute for testing, but it
- 41:02help us know what to look for on the
- 41:06chart.
- 41:07Right? Let's see.
- 41:11As you can see, is automatically fixing,
- 41:15reviewing possible bugs and ambiguities,
- 41:18possible duplicate exit alerts, and it's
- 41:21going to fix the code by itself. So just
- 41:25be aware that we might have a partially
- 41:30working code. It might not be completed.
- 41:34Uh
- 41:37so if it's not working on the first
- 41:39trial, you just keep on asking codeex to
- 41:43fix because trading view is going to
- 41:44give you what's not working and you got
- 41:48to go back and forth maybe a few time.
- 41:50I'm not going to do this right now.
- 41:53Okay,
- 41:55now we're asking now write
- 41:59the final fixed code
- 42:03ready to copy and paste
- 42:08into trading view.
- 42:11So I'm going to fix it later if it's not
- 42:13working right now. I'm going to just
- 42:15show you a version that is already done
- 42:19by me.
- 42:20It's very similar but with more complex
- 42:23rules, more advanced rules just to show
- 42:27you guys. [snorts] Let's see.
- 43:25Here
- 43:29he comes.
- 43:41We're going to create a new strategy
- 43:48and we're going to copy and paste the
- 43:51code inside of Trading View.
- 43:54We're going to save with the name save
- 43:58script
- 44:00New York opening range breakout funer
- 44:03pro.
- 44:05Save. And we're going to add it to the
- 44:07shot.
- 44:09Now, as it's um
- 44:14compiling, it might find
- 44:18some errors. Like, as you can see, it
- 44:20just found an error. We're going to go
- 44:22back to Codeex, give it the error and
- 44:26ask it to fix it and give us back the
- 44:29full code. Now, for the purposes of this
- 44:31live, we're going to have the full code.
- 44:33I'm going to show it to you the next
- 44:34time. I don't want to waste your time
- 44:37right now. Okay, write the full final
- 44:42code. Fix it. Let me see if it can make
- 44:45it within the end. But you're going to
- 44:48find something that look like this.
- 44:52This is one of the the orb strategy that
- 44:55I coded and it's going to detect the
- 45:00exact range is going to place your
- 45:02stop-loss, your entry point and your
- 45:04takerit and most importantly
- 45:08it's going to give you some
- 45:12reports such as key stats like total
- 45:16profit and loss into the last April
- 45:19July. So it's three month risking 1% per
- 45:22trade. It makes 3.51
- 45:25with a 3.28 draw down. Uh 58%
- 45:31profitable trades. Profit factor 1.2 and
- 45:34a lot of um a lot of
- 45:39key metrics.
- 45:41Okay.
- 45:43And we're going to talk about all of
- 45:44these in detail in the next sessions as
- 45:47well as every trades taken taking in
- 45:52consideration
- 45:54the best
- 45:57the best uh set of
- 46:02uh historical
- 46:04um data which is more or less 40 ticks
- 46:08per bar with high definition.
- 46:12uh is going to
- 46:14execute the the script on the bar
- 46:16clause. We added some I added some
- 46:19commission 0.525 per contract. I added
- 46:23two ticks of of slippage. I added one
- 46:26tick of extra order execution delay with
- 46:30it's very similar to what happens in
- 46:32reality as well as inputs area where you
- 46:35can put all your data. So you're gonna
- 46:38find yourself into
- 46:41something that look like this. And you
- 46:43can go back in time and back test more.
- 46:45It's going to take more time. After
- 46:47that, we're going to do uh some
- 46:50optimization,
- 46:52some validation, and then deploy it
- 46:55live. Let me see if it picks up the code
- 46:57in the meantime. If not, no worries.
- 46:59We're going to do it offline.
- 47:02[snorts]
- 47:04No variables alternative
- 47:07on character use the block copy button.
- 47:10Let me let me try again.
- 47:13Let me try again. But it's just this
- 47:16first
- 47:20should work.
- 47:25Just added few more.
- 47:29Here it is. Our opening range script is
- 47:32now ready. As you can see it it okay we
- 47:37have a problem with impagination.
- 47:41Okay. This should move this should stay
- 47:44fixed into the chart but no problem we
- 47:46can fix that very easily. We have our
- 47:48session start time. We have our session
- 47:50end time. We have our opening
- 47:53uh range duration risk to reward
- 47:55position sites in contracts and the bug
- 47:57mode to pigs everything else. We can use
- 48:01we can choose the sides we can use this
- 48:03we can use this
- 48:06for example
- 48:09commission 0.25 25 per contract
- 48:13and one tick more execution delay. One
- 48:17tick, [snorts] one tick of sleepage.
- 48:20There it goes. Let's see. And you're
- 48:22going to have your report.
- 48:25Okay, this this is not looking good, but
- 48:28we're going to work on that with
- 48:30optimization. Okay, you can go even for
- 48:34355 and it's going to do exactly it's
- 48:38going to tell you exactly what to do and
- 48:40when to do it.
- 48:44Okay. Uh so we're going to fix it. No
- 48:47worries. We're going to fix it and it's
- 48:49going to look much better something like
- 48:51this. But you just saw how starting from
- 48:56an idea and hypothesis we define the orb
- 49:01using the XA rules.
- 49:04Right? Then we created a detailed prompt
- 49:08for codeex that you can use for any
- 49:10other hypothesis you might have. We used
- 49:13codeex to generate the pine script. We
- 49:16copied the script into trading view. We
- 49:18inspected the trading range, the
- 49:20entries, the stop-loss, the target and
- 49:22the session behavior. And we also looked
- 49:25how to debug a problem without asking
- 49:29codeex to rewrite everything from
- 49:32scratch. Just giving back the errors or
- 49:34what we're seeing right now. I'm going
- 49:35to say, okay, the range stays stuck in
- 49:38the chat is not moving with the with the
- 49:41candles. Please fix it. We can also
- 49:44provide some screenshot. Okay. And
- 49:49this is the process that we will
- 49:53continue throughout this project. The
- 49:56first version is not supposed to answer
- 50:00every question. It is supposed to create
- 50:03a reliable starting point. Now we have a
- 50:07baseline that can generate a list of
- 50:10trades. And that list of trade is what
- 50:13we need for the next lesson because the
- 50:17next question is no longer can we hold
- 50:22this idea. The next question is does
- 50:25this idea still make sense when we
- 50:28analyze the evidence.
- 50:31That is where real research begins.
- 50:36Thank you guys for being here with me
- 50:37today. Uh you can find the full video
- 50:41into
- 50:44Thunder Pro YouTube channel and on which
- 50:48is my channel. You can find the name
- 50:50right there. And you're going to find it
- 50:52also in
- 51:14Challenge instant futures
- 51:33trading
- 51:35quanti.
- 51:40Thank you so much. Have a great day and
- 51:42see you soon. Bye.
About this transcript
This page contains the full transcript of CODING TRADING AUTOMATIONS | July 24 | Michele Rossi by FunderPro, generated from the public captions YouTube serves with the video. The transcript has 5,360 words across 906 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.