0bps

Strategy vault / Breakout

STARC Channel Backtest Strategy

The STARC Channel Backtest Strategy is a quantitative trading strategy based on the STARC indicator. The strategy constructs the upper and lower STARC channels to generate breakout buy and sell trading signals. It…

Pine ScriptBreakoutSMAATR
Author
ChaoZhang
Complexity
Starter · 45 lines
Parameters
4
Backtest bar
2h · intraday
Tested on
BTC/USDT · futures

IMG

Overview

The STARC Channel Backtest Strategy is a quantitative trading strategy based on the STARC indicator. The strategy constructs the upper and lower STARC channels to generate breakout buy and sell trading signals. It also incorporates long and short position switching mechanisms to adapt to different market environments.

Strategy Principle

The core of the STARC Channel Backtest Strategy is the STARC indicator, which includes:

  • Baseline: n-day simple moving average SMA
  • Upper band: SMA + K × Average True Range ATR
  • Lower band: SMA - K × ATR

It generates a buy signal when the closing price breaks through the upper band, and a sell signal when the closing price breaks through the lower band.

The strategy calculates the upper and lower rails of the STARC channel daily and judges if the closing price breaks through them to generate trading signals. It also sets a reverse parameter to switch between long and short positions to adapt to different market conditions.

Advantage Analysis

The STARC Channel Backtest Strategy has the following advantages:

  1. Construct upper and lower channels with the STARC indicator, good backtesting results;
  2. Built-in long and short position switching mechanisms to adapt to various market environments;
  3. Flexible parameter settings, both K values and moving average lengths can be adjusted and optimized;
  4. Clear and easy-to-understand strategy rules that are easy to understand and implement;
  5. Visualized indicators to intuitively judge market positions.

Risk Analysis

The STARC Channel Backtest Strategy also has some risks:

  1. The STARC indicator is often used for medium-long term trading, and short-term results may not be optimal;
  2. Breakout trading is prone to getting caught in whipsaws which requires strict stop losses;
  3. Improper reverse parameter settings can lead to excessive frequent trading;
  4. Improper parameter optimization can lead to curve fitting.

The following measures should be taken to mitigate risks:

  1. Select appropriate trading cycles, such as daily and other medium-long term cycles;
  2. Set reasonable stop loss positions to control single trade losses;
  3. Carefully set reverse parameters to avoid excessive switching of positions;
  4. Multi-parameter optimization to prevent overfitting.

Optimization Directions

The main optimization directions for the STARC Channel Backtest Strategy include:

  1. Parameter optimization: adjust moving average lengths, K values, ATR cycles and other parameters to find the optimal parameter combination;
  2. Add stop loss mechanisms: set trailing stop loss, time stop loss, percentage stop loss etc. to control risks;
  3. Incorporate other indicators: add trading volume, Bollinger Bands etc. for filtration to improve efficiency;
  4. Dynamically adjust parameters: automatically optimize and adjust parameters based on market changes to improve stability.

These optimization directions can improve the strategy's return and stability while controlling risks.

Conclusion

The overall effect of the STARC Channel Backtest Strategy is good. It implements medium-long term breakout trading based on the STARC indicator. The advantage of the strategy is using the STARC channel to generate stable trading signals, while setting reverse mechanisms to adapt to market changes. We also need to mitigate risks by setting stop losses and optimizing parameters to make the strategy more stable and efficient. In general, this strategy is an effective tool for medium-long term breakout trading.

Parameters

NameDefaultWhat it controls
v_input_15LengthMA
v_input_215LengthATR
v_input_31.33K
v_input_4falseTrade reverse

Source Pine Script

/*backtest
start: 2023-11-04 00:00:00
end: 2023-12-04 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 23/04/2018
// A type of technical indicator that is created by plotting two bands around 
// a short-term simple moving average (SMA) of an underlying asset's price. 
// The upper band is created by adding a value of the average true range 
// (ATR) - a popular indicator used by technical traders - to the moving average. 
// The lower band is created by subtracting a value of the ATR from the SMA.
// STARC is an acronym for Stoller Average Range Channels. The indicator is 
// named after its creator, Manning Stoller.
//
// You can change long to short in the Input Settings
// WARNING:
//  - For purpose educate only
//  - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="STARC Bands Backtest", overlay = true)
LengthMA = input(5, minval=1)
LengthATR = input(15, minval=1)
K = input(1.33, minval=0.01, step = 0.01)
reverse = input(false, title="Trade reverse")
xMA = sma(close, LengthMA)
xATR = atr(LengthATR)
xSTARCBandUp = xMA + xATR * K
xSTARCBandDn = xMA - xATR * K
pos = iff(close > xSTARCBandUp, 1,
       iff(close < xSTARCBandDn, -1, nz(pos[1], 0))) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1, 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	   	    
barcolor(possig == -1 ? red: possig == 1 ? green : blue ) 
plot(xMA, color=blue, title="MA")
plot(xSTARCBandUp, color = green, title="UpBand")
plot(xSTARCBandDn, color=red, title="DnBand")

Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-05. 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/STARC-Channel-Backtest-Strategy.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