0bps

Strategy vault / Mean reversion

Price Reversal Strategy Guided by Price Channel

The price reversal strategy guided by price channel calculates the center line of the price channel to determine the trend direction of price fluctuations. It generates long and short signals when the price…

Author
ChaoZhang
Complexity
Intermediate · 66 lines
Parameters
13
Backtest bar
1m · intraday
Tested on
BTC/USDT · futures

IMG

Overview

The price reversal strategy guided by price channel calculates the center line of the price channel to determine the trend direction of price fluctuations. It generates long and short signals when the price approaches the channel center line. This strategy combines multiple filter conditions to search for high probability trading opportunities.

Strategy Logic

The core indicator of this strategy is the price channel center line. It is calculated as the average of the highest price and lowest price of the most recent 30 candlesticks. When the low is higher than the center line, it is considered an uptrend. When the high is lower than the center line, it is considered a downtrend.

The strategy only generates trading signals when the trend background changes. That is, in an uptrend background, it goes short only when the candlestick turns red. In a downtrend background, it goes long only when the candlestick turns green.

In addition, the strategy also sets double filter conditions: candlestick body filter and price channel bars filter. Signals are triggered only when the candlestick body volume is greater than 20% of the average value, and there must be consecutive trend signals within the filter cycle to open positions.

Advantage Analysis

This strategy combines trend, value area and candlestick patterns, which is an efficient reversal trading strategy. The main advantages are:

  1. Using the price channel to determine the major trend and avoid being misled by range-bound markets.
  2. Selecting price levels near the price channel center line, which is the classic low-buy-high-sell area.
  3. Candlestick body and channel bars filters increase signal quality and reduce false signal rates.
  4. Open positions only at obvious reversal points to avoid chasing highs and selling lows.

Risks and Solutions

The main risks of this strategy come from missing price reversal points and unnecessary waiting for signals. It can be optimized in the following ways:

  1. Adjust the strictness of filter conditions and reduce filtering standards to decrease missing trades.
  2. Increase position size in the early stage of reversal trend to capture trend profits.
  3. Combine other indicators to judge the signal strength and intervene in filters manually.

Optimization Directions

This strategy can be optimized in the following aspects:

  1. Optimize parameters like the price channel period, number of channel bars etc.
  2. Add stop loss strategy to stop loss when loss reaches a certain percentage.
  3. Combine trading volume to intervene in filter strength. For example, relax filters when trading volume amplifies.
  4. Add machine learning model to judge probability of trend reversal, replacing simple filters.

Conclusion

The price reversal strategy guided by the price channel determines reversal points through price channels, and sets double filter conditions to generate high quality signals. On the basis of parameter tuning and risk control, it is a reliable quantitative strategy.

Parameters

NameDefaultWhat it controls
v_input_1truelong
v_input_2trueshort
v_input_330PriceChannel Period
v_input_4truePriceChannel Bars
v_input_5trueUse color-filter
v_input_6trueUse body-filter
v_input_7falseNeed trend Background?
v_input_81900From Year
v_input_92100To Year
v_input_10trueFrom Month
v_input_1112To Month
v_input_12trueFrom day
v_input_1331To day

Source Pine Script

/*backtest
start: 2023-11-19 00:00:00
end: 2023-11-26 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Noro
//2018

//@version=2
strategy(title = "Noro's PriceChannel for D1 v1.0", shorttitle = "PriceChannel D1", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100.0, pyramiding = 0)

//Settings
needlong = input(true, "long")
needshort = input(true, "short")
slowlen = input(30, defval = 30, minval = 2, maxval = 200, title = "PriceChannel Period")
pcbars = input(1, defval = 1, minval = 1, maxval = 20, title = "PriceChannel Bars")
usecol = input(true, "Use color-filter")
usebod = input(true, "Use body-filter")
needbg = input(false, defval = false, title = "Need trend Background?")
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")

src = close

//PriceChannel
lasthigh = highest(src, slowlen)
lastlow = lowest(src, slowlen)
center = (lasthigh + lastlow) / 2

//Trend
ub = low > center ? 1 : 0
db = high < center ? 1 : 0
trend = sma(ub, pcbars) == 1 ? 1 : sma(db, pcbars) == 1 ? -1 : trend[1]

//Body
body = abs(close - open)
abody = sma(body, 10)

//Signals
up = trend == 1 and (close < open or usecol == false) and (body > abody / 5 or usebod == false)
dn = trend == -1 and (close > open or usecol == false) and (body > abody / 5 or usebod == false)

//Lines
plot(center, color = blue, linewidth = 3, transp = 0, title = "PriceChannel Center")

//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 80)

//Trading
if up
    strategy.entry("Long", strategy.long, needlong == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))

if dn
    strategy.entry("Short", strategy.short, needshort == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
    
if time > timestamp(toyear, tomonth, today, 23, 59)
    strategy.close_all()
    

Published by ChaoZhang on the FMZ strategy square · last modified 2023-11-27. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Price-Reversal-Strategy-Guided-by-Price-Channel.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open