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