0:02 In one of our previous videos, we built
0:05 a trading bot using one of the most
0:08 powerful indicators we have ever tested,
0:10 showing you every secret and trick from
0:13 Pinescript. But today, we are going one
0:16 step further. That bot worked well, but
0:19 it had one big problem. It didn't avoid
0:23 ranging periods. It took every signal
0:25 even when the market had no momentum.
0:28 And as you might expect, that's a recipe
0:30 for losing trades. So, what's the
0:34 solution? In one word, volume. In this
0:37 video, we'll upgrade our bot by adding a
0:40 volume indicator and test how it impacts
0:42 our performance. You will learn how
0:45 volume indicators work, how to use them
0:47 in Pinecript, and which one actually
0:50 improves the strategy. My name is ATP,
0:54 and let's get started. [Music]
1:08 For those of you who watched our
1:10 previous tutorial, you'll remember that
1:13 we built a brand new pine script
1:15 strategy using our custom purple cloud
1:18 indicator, which by the way is still the
1:21 top performer in our testing series.
1:23 That indicator gave us clean buy and
1:26 sell signals directly on the chart. And
1:29 in that video, we also coded fully
1:32 automated stop- losses and take profits.
1:34 If you don't remember or maybe you
1:36 missed it, I've left the link in the
1:39 description. And so today, we'll
1:41 continue our work. We are going to
1:44 upgrade the same strategy by adding one
1:46 of the most important and often
1:50 overlooked elements in trading, a volume
1:53 indicator. In simple terms, volume tell
1:55 us how much is being traded at any given
1:59 time. It shows the level of activity
2:01 behind price moves. Think of it like
2:04 this. When price is going up but volume
2:07 is low, there is not much conviction.
2:10 That move could be weak or even fake.
2:13 But when both price and volume are
2:16 rising, that's a sign of strength.
2:18 Volume indicators help us detect that
2:20 hiden force in the market. They don't
2:23 predict direction by themselves, but
2:25 they tell us if there is enough power
2:27 behind the signal to make it worth
2:30 taking. And that's exactly why they are
2:32 so useful in trading bots. If we can
2:35 filter out low volume setups, we can
2:37 avoid many of the fake breakouts and
2:40 choppy trades and focus only on the
2:43 moves that actually have potential.
2:45 There are dozens of volume indicators
2:47 out there. Some basic, some very
2:50 advanced, but today I will show you
2:52 three of my favorites that work great
2:55 with algorithmic strategies. The first
2:57 volume indicator we are going to test is
3:00 the volume oscillator. And the good news
3:02 is that it's built directly into Trading
3:05 View. Here's how it works. The volume
3:08 oscillator compares two moving averages
3:11 of volume, one fast and one slow, and
3:13 shows the percentage difference between
3:16 them. When the fast average is higher
3:18 than the slow one, the oscillator is
3:21 positive, which means volume is
3:24 increasing and momentum is picking up.
3:26 When it's negative, volume is fading.
3:29 It's a simple but effective way to
3:31 measure volume. And in our case, we are
3:34 going to use it as follows. will only
3:36 allow trades when the oscillator is
3:38 above zero, meaning that short-term
3:41 volume is stronger than usual. Let's now
3:44 head over to the pine script editor and
3:46 I will show you how to add this volume
3:49 filter to our existing bot. So, at the
3:52 top we have the purple cloud code which
3:54 handles the entry signals followed by
3:57 the logic for our stop- losses and take
4:00 profits which define our exits. So far,
4:03 that's all we have implemented. What we
4:05 need to do now is create a dedicated
4:08 space where we will insert the code for
4:10 our volume indicator. To keep the code
4:12 clean, I'm going to add it right after
4:15 the purple cloud section. Let's start by
4:18 adding a comment block double slashes
4:21 and I will write volume indicator. Next,
4:24 I will open the volume oscillators pine
4:26 script source code which is available by
4:29 default and copy the entire code. It's
4:32 written in version six of pine script
4:35 just like our strategy. So everything
4:38 will be consistent. Now I will paste
4:41 that code into our script right here.
4:43 Then I'm going to remove the plot
4:45 statements because in my experience
4:48 trading view can't render histogram
4:50 style plots and strategy markers on the
4:53 same script very well, at least not
4:56 consistently. I will also group the
4:58 inputs of this volume indicator using
5:00 the group function. I will label it
5:03 volume so that in the strategies input
5:06 menu each group of inputs is clearly
5:09 separated. First the purple cloud then
5:12 volume and then risk management. Now
5:14 let's define the volume condition we
5:17 want to use. As I explained earlier,
5:19 when the volume oscillator is above
5:22 zero, it means volume is increasing,
5:24 which is exactly the confirmation we are
5:27 looking for. So I will create a new
5:30 condition and name it volume condition.
5:32 And I will set it to true when the
5:35 oscillator value is greater than zero.
5:37 This way we know that the market has
5:40 enough activity to justify a trade
5:43 whether it's long or short. Now let's
5:45 plug this into our entry logic.
5:48 Currently we only check for the purple
5:50 cloud signals. What we want is to
5:53 combine that with our volume condition.
5:55 So in the line where we define the lung
5:57 condition, we will add and volume
6:00 condition like this. And I will do the
6:02 exact same thing for the short
6:05 condition. Once I save the script and
6:07 update the chart, I can already see that
6:10 the bot is now only taking entries when
6:13 both the purple cloud gives a signal and
6:15 the volume oscillator is above zero.
6:17 This simple filter should already help
6:20 eliminate lowquality trades and improve
6:23 the overall consistency of the strategy.
6:25 Just to give you a quick idea of how
6:28 much this volume can help, I run a
6:30 version of the strategy without any
6:34 volume condition. Apply to the AUD NZD
6:36 pair on the 1 hour time frame. The
6:40 results, a win rate close to 33% and the
6:42 profit factor under one after more than
6:45 500 trades. Now, let's take a look at
6:48 the version with a volume oscillator.
6:51 the win rate jumps to 40 and a half% and
6:54 the strategy generates fewer trades but
6:56 with a significantly better profit
6:58 factor and more consistency. So even
7:01 with just one small change adding a
7:03 simple volume filter we are already
7:06 seeing a clear performance improvement.
7:09 And now you might be thinking can we do
7:12 even better? Let's find out by testing a
7:14 second volumebased indicator. And this
7:16 one is actually more popular in the
7:19 trading community. I'm talking about the
7:23 average directional index or ADX. While
7:25 it's usually seen as a strength
7:27 indicator, it comes from price and
7:30 volume data and can be really effective
7:33 at filtering out weak market conditions.
7:36 The rule of thumb is when the ADX value
7:39 is above 20, it usually means the market
7:42 is trending either up or down. If it is
7:45 below 20, the market is considered to be
7:48 in a sideways phase. Let's now test the
7:51 ADX and see how it performs in our
7:54 strategy. First, I will open the ADX
7:57 source code, which is also available by
8:00 default inside Trading View. Again, it's
8:03 written in Pinescript version 6, so it's
8:06 fully consistent with our strategy. Now
8:09 I will go back to our strategy file and
8:11 I will replace the volume oscillator
8:14 code with the ADX logic. I will paste
8:16 the code right into the same place. And
8:18 once again I'll remove the plot
8:21 statement. To keep things clean, I will
8:24 also add a group label to the ADX inputs
8:27 so they appear nicely in the strategy
8:30 input menu. Now let's define our volume
8:33 condition. As I told you earlier, when
8:36 the ADX value is above 20, it usually
8:38 means the market is trending. In the
8:41 code, the ADX value is stored in a
8:44 variable called sik. So, we will create
8:47 our new condition like this. SIK above
8:50 20. After saving and refreshing the
8:52 strategy, we can see that it's now
8:55 working correctly. Trades are only
8:58 triggered when the ADX is above 20. But
9:01 now let's look at the performance with
9:04 the ADX volume active applied again to
9:07 the AUD NZD on the 1 hour chart. The win
9:11 rate improves to close to 39% which is
9:13 better than the base version but still
9:17 slightly lower than the 40 and 12% we
9:20 got with the volume oscillator. So yes,
9:22 it's an improvement but not the best
9:25 result so far. And that bring us to our
9:28 third and final test. And this one is a
9:30 bit more advanced. It's called the
9:33 Wadatar Explosion. And while the name
9:35 might sound dramatic, it's actually a
9:37 brilliant tool for detecting powerful
9:41 breakouts backed by volume. Just so you
9:43 know, there are several versions of this
9:46 indicator out there, both free and paid.
9:49 For this video, I'm using a free custom
9:51 script by this developer right here,
9:53 which you can find directly on Trading
9:57 View by searching water explosion v2.
10:00 This version give us everything we need.
10:02 The histogram that measures momentum and
10:05 the explosion line that acts as a
10:07 dynamic threshold. When the histogram
10:10 breaks above the explosion line, it
10:12 means volume and momentum are both
10:15 increasing. And that's exactly what we
10:18 want. Now since this is a custom script,
10:20 it may not be written in the latest
10:23 version of pine script and in this case
10:26 it isn't. It is the version two which
10:28 won't work if we simply copy and paste
10:32 it into our strategy. So instead of
10:34 rewriting it from scratch, I have
10:37 already updated this script to version
10:39 six. If you want, you can access the
10:42 updated code for free in my Discord. The
10:46 link is in the description. Once inside,
10:48 go to the free materials channel and
10:49 there you will find the wadatar
10:53 explosion version 6 ready to use. Now
10:56 let's copy that updated version and add
10:59 back to our pine script strategy. We
11:01 replace the previous volume filter in
11:04 this case the adx section by pasting the
11:07 wateratar code in its place. As usual, I
11:09 will remove the plot lines and I will
11:12 also group the inputs using group equal
11:16 volume just like we did before. Now it's
11:19 time to set up our volume condition. And
11:21 this one is a little more complex than
11:23 the others because the water attack
11:26 explosion combines both momentum and
11:28 volume and we want to make sure that
11:31 both align before allowing a trade. So
11:33 here's what we are going to do for a
11:36 long trade. We want to check two things.
11:38 First, the histogram bar needs to be
11:41 green, meaning bullish momentum. And
11:43 second, that green bar needs to be above
11:46 the explosion line, meaning strong
11:48 volume. For a short tra, it's the
11:51 opposite. The histogram needs to be ref,
11:54 meaning bearish momentum, and that red
11:56 bar needs to be also above the explosion
11:59 line. In the script, those two values
12:01 are typically named trend up and trend
12:05 down for the histogram and E1 for the
12:07 explosion line. So the conditions will
12:10 look something like this. Volume long
12:13 condition equals trend up greater than
12:16 E1 and volume short condition equals
12:20 trend down greater than E1. Once these
12:22 are defined, we will simply plug them
12:25 into our entry logic just like this.
12:28 After saving and updating the chart, we
12:30 now have a bot that only enters trades
12:33 when the purple cloud gives a signal and
12:36 the water explosion confirms strong
12:39 momentum with high volume. However, as
12:41 you can see, even with this volume
12:43 active, the bot is still taking some
12:46 fake signals. So, what can we do?
12:49 Simple. We adjust the indicators inputs.
12:52 Let's go to the settings menu. Open the
12:55 input tab for the volume indicator. In
12:57 this case, the water explosion and
13:00 change a few things. For this test, I'm
13:02 going to use the following values.
13:07 Sensitivity at 70, fast EMA at 30, slow
13:10 EMA at 40, and Ballinger bands length at
13:14 25, and then click on okay. As you can
13:16 see, the bot now filters out several
13:19 week signals. And here's the exciting
13:22 part. With these optimized settings, the
13:25 win rate jumps to over 41% and the
13:28 profit factor even outperforms what we
13:30 got with the volume oscillator, making
13:34 this version our best one so far. So,
13:36 what can we take from this? Volume
13:39 matters, and even a basic filter can
13:41 drastically improve your trading bots's
13:43 performance. But more importantly,
13:45 different volume indicators work
13:48 differently on each market. Today we
13:51 tested three volume indicators, but you
13:53 can apply the exact same approach to any
13:56 other indicator you want to test. Now,
13:58 if you are serious about testing
14:01 different indicators and finding what
14:03 truly works, I built a tool exactly for
14:06 that. The indicators testing bot lets
14:09 you test any strategy using over 90
14:12 indicators with support for custom
14:15 filters, exits, session rules, and more.
14:18 All automated. It's what I use behind
14:20 the scenes to run these back tests in
14:23 minutes instead of hours. You will find
14:25 the full description and the free user
14:28 guide on my website if you want to try
14:30 it out. The link is in the description.
14:33 And that's it. I hope this video helped
14:35 you understand how to improve your
14:38 strategies using volume. And if it did,
14:40 don't forget to leave a like, subscribe,
14:42 and let me know in the comments which
14:44 type of indicator you want me to add to
14:47 this trading bot. Thanks for watching
14:49 and I will see you in the next one. Bye-bye.