Dynamic Anchored Regression Channel

Dynamic Anchored Regression Channel

Regression channels are a powerful tool for analyzing trends. They plot a central “mean” line of a trend and upper/lower bands to measure volatility, helping traders identify overbought or oversold conditions.

However, most standard regression channels are based on a “rolling” fixed period (e.g., the last 100 bars). This can be limiting. What if you want to analyze a trend not from “100 bars ago,” but from its specific starting point—like a major market bottom or a key news event?

This indicator solves that problem. It allows you to anchor a regression channel to a specific date and time, creating a dynamic tool that grows and adapts with your chart.

How It Works & Key Features

The logic is simple but effective. Instead of defining a lookback period, you define a fixed starting point in the past.

  1. Anchoring: You set a StartDate and StartTime in the code’s configuration. The indicator finds this single bar on your chart and uses it as the permanent “anchor” (Bar 0) for all its calculations.
  2. Dynamic Recalculation: The “dynamic” part is key. The channel is always calculated from that single anchor point up to the current, most recent bar.
  3. Growing Channel: As each new bar forms, the indicator automatically recalculates the entire channel’s slope, intercept, and standard deviation. This means you can watch the trend’s path and volatility evolve in real-time, all based on its original starting point.

Main Use Cases

The primary benefit of this indicator is adding historical context and objectivity to your trend analysis.

  • Analyze Trends from a Specific Event: This is the most powerful feature. You can anchor the channel’s start to:
    • A major market bottom or top.
    • A significant news release (e.g., an earnings report or central bank decision).
    • The beginning of a new year, quarter, or month.
  • Objective Trend Analysis: It removes the guesswork of picking the “right” lookback period (e.g., 50, 100, or 200). Your analysis is based on the trend’s entire life since the anchor point you selected.
  • Visualize Volatility: By watching the standard deviation bands, you can see if a trend is expanding (volatility increasing, bands widening) or contracting (volatility decreasing, bands narrowing) as it matures.

Configuration

You can easily configure the channel by editing the “USER INPUTS” section at the top of the code.

  • StartDate: Enter the starting date for the channel. The format must be YYYYMMDD (e.g., 20250128 for January 28, 2025).
  • StartTime: Enter the starting time. The format must be HHMMSS (e.g., 150000 for 3:00:00 PM).
    • Important: This time is based on your chart’s time (the time displayed on the x-axis), not necessarily your local computer time.
  • StdMultiplier: (Default: 2). This controls the width of the upper and lower bands. A value of 2 is standard (capturing ~95% of price action), but you can use 1 for a tighter channel or 3 for a wider one.

ProBuilder Code

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

avatar
Register or

Likes

avatar
Related users ' posts
yas getting showtrend error undefined variable
MaoRai54 Anche a me non si carica e poi manca definizione di variabile SHOWTREND
Iván Sorry. You should add new line after line 21. showtrend=1 // ------------------...
Iván sería así //------------------Inputs------------------------------ linreglength = 11//i...
Doddge Muchísimas gracias Iván, está genial.
superfalcio holaaa, have you run some statistics?
Msport71 Thank You very much
elcortijoverde Muy buen trabajo.Intuitivo y claro.Gracias por tu dedicación y aportación.
Nicolas change the last line with: return v coloured(r,g,b) style(line,2), v+band coloured(168,168,1...
Paolo.B Thanks ... works as i wanted.
Kanamax Bonjour Nicolas, comme Paolo.B je souhaiterais utiliser cette indicateur au sein d'un code. ...
Nicolas Please open a topic in ProScreener forum with your query, I'll reply you there. Thank you.
manafull Thanks Nicolas, I post my question, along with the codes I am trying to convert from your in...
Nicolas I replied to your post here: https://www.prorealcode.com/topic/screener-for-rsi-and-linear-r...
Nicolas How to import file page: in the help section of the website explains howto
kenssa import through the indicator page/window in the Proreal time
chicoteca Buenas, no consigo que se me muestre en el chart de DAX. ¿Cómo procedo? Gracias.-
redactv7 On my charts, the indicator doesnt go on the upper pannel, on prices, but under like an osci...
Nicolas apply in on the chart, look at this how-to video: https://www.prorealcode.com/blog/video-tut...
jonpt88 interesting code thanks!
Jack86gv Ciao Nicolas, e possibile fare uno screener con questo codice ovvero vorrei sapere quando il...
Nicolas https://www.prorealcode.com/topic/screener-regressione-canale/
wharfdog Hi Nicolas, Fantastic work, I'm really grateful for this. I was wondering if it would be ...
cfta Hi Fulvio, many thanks for sharing this clever indicator, much appreciated. As Pepsmile ment...
cfta Sorry adding the PRT to code didn't work in the above comment so I guess we will have to set...
juanj Something appears to be wrong with this formula as graphing t shows t to almost never be wit...
Nicolas S11 variable is not a loop but a ratio calculation. In real time the codes is processed on e...
Stephan_V Nicolas, This regression delivers damn good results, especially for trends ! I'm wonde...
Nicolas Least square method is used here in order to get the perfect y = ax2 + bx + c
Canale di Fill By Filippo si si... farò un video a breve
AngelPujalt ok. Gracias.
Stenozar Hi Filippo, any news about your video to explain how to use this indicator? thanks
Marcot18 Buonasera Maurinho, interessante l'indicatore che ha i proposto ma ancora di più interessant...
maurinho ciao marcot18 l'indicatore pubblico /proffessional lo puoi scaricare si chiama progo di will...
james effiong This strategy looks good
KarlBenjamin This "indicator" alone has completely changed my algorithms for the better! Id even go as fa...
ashee CAN YOU SHARE MT4 FILE
coyP Big thanks ! Can you explain me how can I put this ON my graph and not under the graph please ?

Top