OPEN-SOURCE SCRIPT

Raff Regression Channel by DGT

Updated
Rᴀꜰꜰ Rᴇɢʀᴇꜱꜱɪᴏɴ Cʜᴀɴɴᴇʟ (RRC)
This study aims to automate Raff Regression Channel drawing either based on ZigZag Indicator or optionally User Preference

The Raff Regression Channel, developed by Gilbert Raff, is based on a linear regression, which is the least-squares line-of-best-fit for a price series, with evenly spaced trend lines above and below. The width of the channel is set by determining the high or low that is the furthest from the linear regression.
Because the channel distance is based off the largest pullback or highest peak within a trend, for effectively drawing and using a Raff Regression Channel it is recommend/required that a Raff Regression Channel is applied to “mature” trends. Knowing this requirement, for better automated drawing results this study benefits from the Zig Zag Indicator, where the Zig Zag indicator is used to help identify price trends and changes in price trends. Option to manually adjust lengths for drawing a Raff Regression Channel is also made available.

snapshot

Using a Raff Regression Channel
Once The Raff Regression Channel is drawn, covering an existing trend, Exᴛᴇɴꜱɪᴏɴ Lɪɴᴇꜱ are drawn to identify ᴛʜᴇ ꜱᴜᴘᴘᴏʀᴛ﹐ʀᴇꜱɪꜱᴛᴀɴᴄᴇ ᴏʀ ʀᴇᴠᴇʀꜱᴀʟ ᴘᴏɪɴᴛꜱ
The trend is up as long as prices rise within this channel. An uptrend may be reversing (not always, but likely) when price breaks below the channel extension. The trend is down as long as prices decline within the channel. Similarly, a downtrend may be reversing (not always, but likely) when price breaks above the channel extension. Moves outside the channel extensions can be indication of a reversal or can denote overbought or oversold conditions

For further details please refer to education post Raff Regression Channel


█ FEATURES
    - AUTO or MANUALLY adjusted Raff Regression Channel and Channel Extentions drawing
    - ALERTs, for Linear Regression Line, Raff Regression Upper and Lower Channel Extentions
    - LSMA, Least Squares Moving Average, in other words Linear Regression Curve


█ SETTINGS
Setting Loopback and Number of Bars are the most important part for The Raff Regression Channel, where ;
    - Lookback, defines where the Raff Regression Channel is starting, it is recommended to set to a trend begining
    - Number of Bars, defines how many bars to be assumed for calculation, or simply stated the end of the Raff Regression Channel drawing (not extentions but the main channel, extentions by default will be drawn till the last bar)

Setting of Loopback and Number of Bars is performed eigher automatically based on Zig Zag indicator or users may prefer to set them manually. If selected automatically then
    - Deviation and Depth values of Zig Zag indicator are used for calculations (enabling visually plotting of ZigZag Lines will help to identify better visually the points), where ;
Deviation, is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot.
Depth, affects the minimum number of bars that will be taken into account when building

Short-term traders may wish to apply the channel to small waves of a trend so they can reduce the value of the Deviation and Depth


█  OTHER CHANNEL CONSEPTS

Linear Regression Channels, , what linear regression channels are? and linear regression channel/curve/slope study
Fibonacci Channels, how to apply fibonacci channels and automated fibonacci channels study
Andrews’ Pitchfork, how to apply pitchfork and automated pitchfork study

Special Thanks to Kiss66000 for his kind suggestion, je vous remercie beaucoup Kiss66000

Disclaimer:
Trading success is all about following your trading strategy and the indicators should fit within your trading strategy, and not to be traded upon solely

The script is for informational and educational purposes only. Use of the script does not constitute professional and/or financial advice. You alone have the sole responsibility of evaluating the script output and risks associated with the use of the script. In exchange for using the script, you agree not to hold dgtrd TradingView user liable for any possible claim for damages arising from any decision you make based on use of the script


Release Notes
update

* adjusting lengths, now available based on date & time whcih makes plottings constant across timeframes, thanks to Arun_K_Bhaskar valuable suggestion
with this update, lenghts adjusting options are ;
- auto : based on zigzag indicator, where deviation and depth options are settings related to zigzag indcator
- manual fixed bars : calculated based on user provided lookback and number of bars inputs
- (NEW) manual date & time : calculated based on user provided start and end date & time

* added standard deviation channels plotting option, thanks to Javafuel suggestion
DGTleastsquaresLinear RegressionlinearregressioncurvelinregraffraffregressionreversalSupport and ResistanceZig Zag Indicator

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 publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer