📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

How I Used AI To Build A Trading Bot

Trades by Matt18:32

Transcription

One of the most common things that I see people asking is, "Can I automate my trading strategy?" Everyone wants to always automate their strategies because who doesn't want to just make money not having to do anything? You don't have to make any decisions or actually try and be a discretionary trader. You don't have to watch the market. You can just have this running in the background, right? It's everybody's holy grail.

Normally, the answer is no. It doesn't work that well. You have to watch the markets a lot, things like that. But in today's world of AI, can I vibe code a trading strategy, get it up and running, and have it running on its own, and can it pass an Apex Trader evaluation? That's the big question that we're going to be solving today.

So, the first step of this process is I am actually using a Mac Mini so that I can keep it on all the time. I run all of my normal trading and streaming. Everything that you see is through a PC. I want to use a Mac Mini for this project just so I can have it running all the time for the automated trading strategies that we're going to be testing.

In order for me to do that, I want to use Ninja Trader uh to run the automated trading strategies and build the program in C sharp, which is the NinjaScript language. Ninja Trader is only for PC. Uh it's not Mac native. So what I'm doing right now is I'm currently remoted into my Mac Mini. I'm installing Parallels through Parallels. I'm installing Windows 11. So, what that means is that now on my Mac Mini, I'll be able to download Ninja Trader and run all of this through Ninja Trader.

This is a massive workaround, but I'm doing this so that I can use my normal computer dayto-day while this is running in the background uh on its own. And this is just unfortunately the easiest way to do that. So, this is the current setup process that I'm doing before I even start vibe coding a trading strategy.

What I will be using here is the Apex 50K accounts. I'm going to be mimicking the Apex 50K accounts using the same parameters. It's what I'm used to trading. I trade 20 of the Apex 50K accounts on my stream every morning through Sierra Chart doing real trading. Doing this bot simulator, I'm just using those parameters as a level of winning or losing so that the threshold remains the same for me so that I have targets that I'm looking for. The profit target on Apex 50K account is $3,000 and the trailing draw down is $2,500. Again, I'm following that same method here. Uh using something that I'm familiar with and that I use every day in order to kind of guide this bot.

Um, you need to look up personally if you are allowed to use a trading bot or whatever. I would obviously recommend never using a trading bot. This is just for the experiment. Uh, you should just pick your own trades and do it discretionarily in my opinion. You need to be able to look up and see the prop firms that you're using. uh how the connections work whether you're connecting Apex or you know Tradeify or any of these other firms to Ninja Trader you need to be able to see how to do that by yourself just by googling reading the docs reading the uh watching the videos etc that they provide again I am just doing a method of using the same parameters in order to give myself parameters for this bot using the same parameters that the 50k account provides I do use 20 of the 50ks on my stream you can use code TBM for 80% off right now uh or go down to the link in the description of the video if you are interested in getting started with prop firms.

Basically, they give you money to trade with. You go through an evaluation. Once you pass, they give you money to trade with and you can take payouts on that. The evaluations are challenging. They're supposed to be, but helps them prove that you're a good trader and then you can start making money from the markets with a lower risk upfront cost.

So, this is Ninja Trader. We're about to jump into ChatGBT to begin this whole entire process. I did want to make a quick note that I'm not talking about how to set everything up in here uh as far as connections to accounts go and things like that. There's a ton of different documents and videos out there on how to connect to any different prop firms that you might have, etc. Since I'm already connected to Apex here, um I just wanted to point that out since you can do your own research on that side.

So, let's go to new Ninjascript editor down here at the bottom plus sign new strategy. Okay, this is where we're going to put in our information. New scalping TBM bot strat. Let's just say this is the AI vibe code strat. Okay, this name space holds strategy in this folder and is required. Do not change it. Add your custom logic here. Perfect. Let's go ahead and say that this is strategy name. Cool. So, there's the future reference. There's the strategy name. So, in theory, it should plug that into the code. Hopefully, we'll see. I've never done this before, by the way. I'm 100% brand new.

Let's say what are the best what's the best scalping strategy? What scalping strategy has the best results for trading NASDAQ futures? Let's see what it says. is I don't know if it's going to get me anything. Yeah, there's no single best option. So, I guess I'm going to be able to get like pick some. We've got an opening range momentum continuation top tier. This would be like an opening range breakout. I believe we can probably call it opening range breakout elite but conditional VWAP deviation mean reversion. Something similar to what I use confirmation via orderflow delta. I trade uh I can trade some VWAP reversions with delta momentum pullback breakout scalping from compression orderflow only scalping overrated for automation so that's not going to work well if I had to pick one for automation and your goal is fully automated which is scalable doesn't really matter statistically defensible yes opening range plus momentum continuation with time filter VWAP bias hard daily loss limit no trading after midday Hey, I actually really like that it's calling out not like calling out having time constraints. I was going to talk about this in case it didn't do it, but I personally don't want to trade I don't want to have my bot trade the overnight session and I like that it has a cut off at midday. So, in my mind, this will run from 8:30 to midday because a lot of times on the overnight session, you get false flags and you know these automated strategies will just trade trade trade trade trade and I don't want to lose this thing necessarily in one day if I can get away with it, right? So let's just go with this time filter VWAP bias daily loss limit no trading after midday. Let's do the opening range momentum first. So let's build this in ninja script for ninja trader. Let's build the opening range breakout orb system. I don't want this since I just talked about time. Let's go ahead and just say like I don't want this to trade before 8:30 or after midday. Let's say on the hard daily loss limit. I'm trying to think of what that should really be here because I do want this to kind of fire off. So, I'm going to say I don't have a hard daily loss limit, but I'm only willing to risk 25 points maximum per trade. Okay, I'm throwing a little bit of a curveball here. I'm saying I would like to look for 10 to 15 points. And so I'm only risking 25 points, which is $500 on the NASDAQ. I'm looking for 10 to 15 points per trade or enabling a tight trailing draw down draw down. If it's 15 points, that trails by five points or I should say tight tight trailing stop-loss. So I'm risking $500 total. I'm ideally looking for 10 to 15 points, which is just base hits. That being said, I'm also interested if it will run to 15 points, then trailing it by five points. I might catch a little bit of momentum there. And I'm only risking $100 off the trailing draw down by doing this. And this will auto all be in theory automated. So, it should be really crispy with doing that. I'm not opposed. I don't love it either, but I'm not opposed to giving it a shot here and seeing what it does. Just go with that and see what it says. I only want to take one contract per trade. I just talked through the daily loss or the uh risk and the take-profit using the opening range breakout system while only trading between 8:30 a.m. Central time and midday.

So, here's a clean Ninja Trader 8 Ninjascript orb scalper for INQ that matches exactly what you asked for. Trades only 8:30 a.m. Central time to 12:00 p.m. Central time. Opening range built from 8:30 Central Ford, one contract only, maxress 25 points per trade. Hard stop. Good. Profit target option 10 to 15 points. Default is set to 12 points. That's okay. That's an assumption. Optional trailing mode once plus 15 trail by five points. One trade per day. Common orb best practice configurable if you want later. Interesting. I don't really trade an orb, so I don't really know. Uh, this is 100% out of my league. Replace the entire file contents with this. I'm wondering if I should I feel like I should clean up the risk side real quick. I think I'm going to take this to allow for three trades per day. A chop filter. I like that idea. Wonder how it would do that. We're going to get a lot more firing with the fivem minute probably which I'm more intrigued with. Okay, so the fiveminute has the highest fake out rate. Good compromise. Still early momentum. Decent for semi-auto system. Still noisy on news day. Slightly lower win rate than the 15minute. Viable but less robust than the 15. Okay, so let's do the 15-minute. So here I'm saying let's do the 15-minute opening range breakout. Let's allow for three trades per day. Cool down bar is equal to one. And let's apply the chop filter. Let's just see what it spits out. So the orb is now set up for 15 minutes. Allow for three trades per day. Apply the chop filter. Skip days when the orb is too wide. Max orb with 35 points. I don't agree with this. I'll be honest. I don't agree with this. I think this should be different. Okay, I'm telling it to get rid of the chop filter. I think that this could be something that would be interesting in part two is to look at the data from the past historical volatility and analyze that to see what the chop filter should be. But I just don't think 35 points is I think it's too tight right now to be honest. Uh I don't think we would have any trades. It's been long bigger than that almost every day in the first minute. So, I'm taking out the uh chop filter and I'm taking out the trailing stop and I'm just going to target um a 10point winner now that I'm taking up to three trades a day. That would be 600 bucks. This could last for 5 days if everything went perfectly. And worst case, you know, I have a couple days that this could be running. So, let's go ahead and do let's go ahead and put this in. Replace your existing strategy code entirely with the version below. Let's copy this code and put it into Ninja Trader.

So now let's just go ahead and do this whole deal right here. All right, we are compiling the fivecoded strategy. I know I don't know how to code at all. Literally zero. This is This is what I got going. Don't think it's going to work to be honest, but we'll see. Everything is green, which I think is good. Okay, so this is now set up. The strategy, the TBM bot strategy is alive. So let's go and put it on the chart. Okay. Or minutes 15. Max trades per day three. Cool B bars after exit one. Max risk in points 25. Profit target in points 10. Trading on the ENQ one minute chart. That is correct. Account Apex on bar close label bot strat. Maximum bars to look back. Bars required to trade 20. Wait until flat. That's good. Enabled. Okay. Now, we wait and see. The next part you'll see will be an update going over the trades, etc. that we will fire off tomorrow morning at 8:30 a.m. Central time potentially.

Order submitted. Target filled. >> Okay, so day one is complete for the bot trading. It took one trade today. It is currently up $200. It was a oneandone day for it. The markets were super trendy. Um, so we took the opening range breakout trade off of the 15-minute high. Uh, and it executed for 10 points in the money. This trade could have been at least 15, if not more. Uh, it could have been a lot more, but I set that profit target to 10 points like we had talked about uh, in the setup and so it took its one trade on a super, you know, trendy day like this. Uh, that's probably what's going to happen every time if it's a little bit more rangebound or a little bit more whippy. Might see some more trades in the future, but one and done. Uh, one for one on the green trades, plus 200. We'll see what tomorrow brings.

Order submitted. Stop filled. One thing to note here is that this is an opening range breakout strategy. So as you see the candle here closed above our entry is way higher. This is not a retest of opening range strategy. It's a breakout which is why the entries are all >> target.

Order submitted. Target filled. Order submitted. Stop filled. Order submitted. Target filled. Order submitted. Stop filled. Order submitted. Target filled. Order submitted. Target filled. Order submitted. Target filled. Order submitted. Stop filled. Order submitted. Stop filled. Order submitted. Target fill. Order submitted. Target filled.

Well, I've been on vacation on a Thursday and Friday and I accidentally left the bot enabled and it blew itself up on Thursday. So, it lasted about a week, which is not terrible given the parameters that we had on it. I think in hindsight, some things that I would change would be to ask the AI what should the take-profit and stop loss be and go with that, not designate my own. Um, I think there was several examples in there where it could have gone better, opened it up more potentially or even tighter. And I'm just I should have asked the AI that. That was one fault. The second thing though is that this is exactly what I anticipated to happen to be honest. I get asked this question all the time. How should I build a trading bot? Can I build a training bot that works, etc. At the end of the day, the markets are always changing. The bots would always need to be getting updated. Yes, there are massive multi-billion dollar companies like Citadel or whatever that are functioning like functioning off of bots and things like that, but for the average Joe, it is not worth it. It is better to be a discretionary trader. In my opinion, I think this video proves it. However, if you think there should be a part two, let me know. Maybe I could fit it a little better. Maybe I try it with some of my strategies. Let me know if you're interested in a part two or if you found this video interesting. Thanks for watching. Make sure you subscribe and press that thumbs up button down below. Peace.