July 15

0 comments

Exploring Price-Time Filtering in Trading

By Jeff Swanson

July 15, 2024

EasyLanguage

The Price-Time Filter Indicator

It's essential to identify genuine market trends for consistent trading success. Many traders find distinguishing between random price fluctuations and real trading signals challenging, which can lead to missed opportunities or false entries. Today, we'll explore an intriguing technique called Price-Time Filtering, designed to filter out market noise and emphasize significant trends with greater clarity.

This article was inspired by Alfred François Tagher's insightful article, "Trend Identification By Price And Time Filtering," featured in the February 2024 issue of Stocks & Commodities magazine. In it, Tagher introduced the Price-Time Filtering technique. This method leverages the power of both price and time to identify trends, making it a robust tool for traders seeking to enhance their market analysis. When applied correctly, this method can provide a clearer picture of market movements and help traders make more informed decisions.

This article will delve into the price-time filtering technique and apply it to several future markets. By the end, we'll have a deeper understanding of how this technique works, its potential advantages, and how to incorporate it into your trading toolkit.

Practical Application of the Price-Time Filter

Imagine trying to listen to a piece of music in a noisy environment. In this scenario, you need some type of filter to remove the noise so you can hear the music more clearly. This is what your canceling headsets do.

In the trading world, price-time filtering isolates trends, allowing you to trade in the overall market direction. don't see the Price-Time filter as a signal generator to go long or short. Instead, it will help align trades with the prevailing market direction, reducing the risk of false signals and improving the consistency of trading results.

Well, that's the theory, anyway. I don't know if it will work, but that's what we're testing with this article.

Implementing the Price-Time Filter in EasyLanguage

Implementing the price-time filtering technique is straightforward with EasyLanguage for those using TradeStation or MultiCharts. Below, I provide code examples for the weekly timeframes, which I plan to focus on in this article. 

EasyLanguagee Code For Price-Time Filter:

{ Price-Time Filtering - Weekly }

Inputs: UpColor(Green), DnColor(Red);
Vars: WeekHi(0), WeekLo(0), WeekCl(0), PriorWeekHi(0), PriorWeekLo(0), Trend(0), WeekKnt(0);

{ Check for end of the week }
If (DayOfWeek(Date) < DayOfWeek(Date[1]) and DayOfWeek(Date[1]) <> 5) or (DayOfWeek(Date) = 5) then begin
If DayOfWeek(Date) = 5 then WeekCl = Close else WeekCl = Close[1];

If WeekCl > PriorWeekHi then Trend = +1;
If WeekCl < PriorWeekLo then Trend = -1;

PriorWeekHi = WeekHi;
PriorWeekLo = WeekLo;
WeekKnt = WeekKnt + 1;
end;

{ Reset weekly high and low }
If DayOfWeek(Date) < DayOfWeek(Date[1]) then begin
WeekHi = High;
WeekLo = Low;
end;

{ Update weekly high and low }
If High > WeekHi then WeekHi = High;
If Low < WeekLo then WeekLo = Low;

{ Plot the trend }
If WeekKnt > 1 then begin
If Trend = +1 then Plot1(High, "Week UP", UpColor);
If Trend = -1 then Plot1(Low, "Week DOWN", DnColor);
end;

Explanation

1. Inputs: These are user-defined parameters for the colors used in the plots.

2. Variables: These store the high, low, and close prices for the current and prior periods, as well as the trend direction and counters.

3. End of Period Check: The script checks if the current day is the week's or month's end and updates the trend accordingly.

4. High and Low Updates: The script continuously updates the highest and lowest prices observed throughout the period.

5. Plotting: The script plots the trend direction based on the evaluated conditions.

Below is an image of a PaintBar indicator using the Price-Time filter. Bearish trends are coloring the price bars red. Bullish trends are in green.

Price-Time Filter example

Price-Time Filter example

Testing the Price-Time Filter

I transformed the indicator into a simple trading strategy to evaluate the effectiveness of the Price-Time Filtering technique. This strategy will buy when the filter indicates an uptrend and sell short during a downtrend. By doing this, we can gauge how well the Price-Time Filter can identify and capitalize on trending markets.

Here's the plan:

  1. Strategy Setup:
    • We'll use the EasyLanguage code for the Price-Time Filtering indicator, which we've already discussed.
    • The strategy will enter a long position when the filter signals an uptrend and enter a short position when it signals a downtrend.
    • We'll be using the Weekly version of the Price-Time Filter.
  2. Testing Parameters:
    • We'll apply this strategy to several futures markets that represent a good basket of unique markets I trade, including:
      • Soybeans (S)
      • Euro Currency Futures (EC)
      • Crude Oil (CL)
      • S&P 500 (ES)
      • Gold (GC)
    • The testing will use daily bars to capture significant price movements over time.
    • We'll be using historical dates from 2000-2023. 
    • Slippage and commission will not be taken into account for this analysis.
  3. Performance Metrics:
    • We'll evaluate the strategies based on key performance metrics such as net profit, maximum drawdown, and net profit vs. maximum drawdown ratio.
    • Additionally, we'll analyze the average duration of trades to understand how long trends typically last.

By converting the Price-Time Filter into a simple strategy and testing it across different futures markets, I aim to provide you with actionable insights into its effectiveness. This practical approach will help you determine if this method can enhance your trading systems and improve your overall trading success. In the following sections, we'll dive into the results of these tests and draw meaningful conclusions to guide your trading decisions.

Price-Time Results

Now it's time to test this indicator on our markets. Below is a table with the results of apply the Price-Time strategy.

S

EC

CL

ES

GC

Net Profit

-31,687

$39,012

$157,480

$31,612

-$112,670

Profit Factor

0.89

1.12

1.36

1.36

1.09

0.79

Total Trades

216

216

200

222

254

Avg.Trade Net Profit

-$146

$180

$787

$142

-$443

Max Drawdown (Intra-Day)

$82,800

$49,056

$117,960

$74,412

$135,650

NP vs. DD

-0.3

0.7

1.3

0.4

-0.8

Some markets yield higher net profits than others which is expected. Soybeans and Gold do not perform well, whereas Crude Oil performs the best.

I couldn't help but notice that the Price-Time filter serves as a momentum or trend indicator. Thus, the markets with higher net profit are likely markets that have some trending characterisitic.

What if we were to invert the trading logic? We'll explore that in the next section.

Inverted Price-Time Results

In this case we're going to do the opposite of the original rules. That is, when we get a long signal, we're going to sell short. Why? We want to test the mean reversion characteristic of the market. We would expect to see results that are opposite of above. 

S

EC

CL

ES

GC

Net Profit

31,687

-$39,012

-$157,480

-$31,687

$112,670

Profit Factor

1.09

0.89

0.73

0.92

0.79

Total Trades

222

216

200

222

254

Avg.Trade Net Profit

$142

-$180

-$787

-$142

-$443

Max Drawdown (Intra-Day)

$74,412

$73,237

$266,450

$74,962

$88,090

NP vs. DD

0.4

-0.5

-0.6

-0.4

1.2

We can see that soybeans and gold do much better while the other market moves into negative territory. This tells me that Soybeans and Gold have mean reverting characteristics while the other markets have more trending characteristics. At least based on this indicator and this indicators hold times. We'll look at hold times in the final table. below.

Let's now create a table with the best results for each market.

Price-Time Best Results

In this table we're going to select the best performing side (Long, Short, or Both) and we'll select the best performing trading style (Trend Following or Mean Reversion)

S
Long MR

EC
Both TF

CL
Both TF

ES
Long MR

GC
Long MR

Net Profit

61,212

$39,012

$157,480

$87,950

$118,270

Profit Factor

1.61

1.12

1.36

1.54

1.71

Total Trades

108

216

200

111

127

Avg.Trade Net Profit

$566

$180

$787

$792

$931

Max Drawdown (Intra-Day)

$32,100

$49,056

$117,960

$40,462

$67,300

NP vs. DD

1.9

0.8

1.3

2.1

1.7

Avg. Bars in Trades

31

36

39

47

29

The weakest market is the Euro Currency Futures. The Price-Time filter does not hold some potential when using the mean reversion version of the indicator.  

The Crude Oil market does best in terms of net profit while talking both  long and short trades, with our filter acting as a trend-following indicator. See the image below for example trades. Click on the image for a larger version.

Price-Time Chart of Crude Oil With Trades

Price-Time Chart of Crude Oil With Trades

The remaining markets (Soybeans, S&P 500, Gold) all do well on the long side, with our filter acting as a mean reverting indicator.

What have we learned?

We have discovered which trading style (mean reversion or trend following) may work well for each market and which side of the market we should trade (long, short, or both).

This can be valuable information! We now have some critical information if we wish to start building trading systems on the daily timeframes for these markets.

Remember, depending on the market, the average holding time for these trades is between 29 days (GC) and 47 days (ES). So, the characteristics we're measuring in this study must unfold over several weeks.

How could you use this indicator?

As stated earlier, the Price-Time filter is not meant to generate trading signals. We used it to perform our market study this way, but it's better as a filter. 

For example, you might use this indicator on the ES market to activate your trading model and start looking for long trades. 

I did not explore the monthly signals in this study. However, the code can be modified to use the monthly closing price to produce an even longer-term filter, which presents a promising avenue for future studies. You will find that code in the original article, requiring a subscription to Technical Analysis For Stocks & Commodities magazine. I recommend the publication highly.

Lastly, if you trade intraday strategies, use this filter on a daily chart to filter which direction you should be trading on your 60-minute chart. This is another idea worth testing.

Jeff Swanson

About the author

Jeff has built and traded automated trading systems for the futures markets since 2008. He is the creator of the online courses System Development Master Class and Alpha Compass. Jeff is also the founder of EasyLanguage Mastery - a website and mission to empower the EasyLanguage trader with the proper knowledge and tools to become a profitable trader.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Learn To Code & Build Strategies
Using EasyLanguage. 

>