PineCodersTASC

TASC 2023.09 The Weekly Factor

█ OVERVIEW

TASC's September 2023 edition of Traders' Tips features an article written by Andrea Unger titled “The Weekly Factor", discussing the application of price patterns as filters for trade entries. This script implements a sample trading strategy presented in the article for demonstration purposes only. It explores how the strategy's equity curve might benefit from filtering trade entries using a specific price pattern.


█ CONCEPTS

Pattern filters represent valuable tools that assess current market conditions based on price movements and determine when those conditions become more favorable for trade entries.

The filter used and tested in this article is a metric called the "weekly factor", which measures the price range over the last five trading days and compares it to the open of the session five days ago and the close of the session one day ago (i.e., the "body" of the five-day period). When the five-day body is small compared to the five-day range, this could indicate "indecision" or "compression", potentially followed by a price expansion. Thus, the weekly factor metric can help identify areas in the market where a period of compression might signal a potential breakout.

This script demonstrates the use of the weekly factor for a sample intraday trading strategy (intended for educational and exploratory purposes only). In this strategy, the entry signal is triggered when a 15-minute bar breaks out of the previous day's high-low range, and the position is closed at the end of the day.


█ CALCULATIONS

The script uses two timeframes:

• The strategy entries are processed on the 15-minute timeframe.

• The weekly factor is obtained from the daily timeframe using the request.security function and the following formula:

math.abs(open[5] - close[1]) < RangeFilter * (ta.highest(5)[1] - ta.lowest(5)[1])

Here, RangeFilter is an input that can be optimized to find the favorable ratio between the five-day body and the five-day range. Smaller RangeFilter values will lead to fewer trade entries. A RangeFilter value of 1 is equivalent to turning off the filtering altogether.

Tools and ideas for all Pine coders: www.tradingview.com/u/PineCoders/
Pine news broadcasts: t.me/PineCodersSquawkBox or twitter.com/PineCoders
TASC: traders.com/
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?