OPEN-SOURCE SCRIPT

Support and Resistance Polynomial Regressions | Flux Charts

已更新
Overview

This script is a dynamic form of support and resistance. Support and resistance plots areas where price commonly reverses its direction or “pivots”. A resistance line for instance is typically found by locating a price point where multiple high pivots occur. A high pivot is where a price increases for a number of bars then decreases for a number of bars creating a local maximum. This script takes the high pivots points but rather than using a horizontal line a polynomial regressed line is used.

It is common to see consecutive higher highs or lower lows or a mixed pattern of both so a classical support or resistance line can be insufficient. This script lets users find a polynomial of best fit for high pivots and low pivots creating a resistance and support line respectively.

Here are the same two sets of high and low pivots the first using linear regressed support and resistance lines the second using quadratic.
快照
快照

Here are the predicted results:
快照
快照

The Quadratic regression gives a much more accurate prediction of future pivot areas and the increase in variance of the data.

Quick Start

Add the script to the chart. Then select a left point and right point on the chart. This will be the data the script uses to calculate a best fit resistance line. Then select another left and right point that will be for the support line.

Now you can confirm your basic settings like the type of regression: Linear Regression, Quadratic Regression, Cubic Regression or Custom Regression.

After confirming the lines will be plotted on the graph.


Custom Polynomial Regression Setting
Polynomials follow the form:
快照

The degree of a polynomial is the highest exponent in the equation. For example the polynomial ax^2 + bx + c has a degree of 2.

Here are the default polynomial options and their equivalent custom polynomial entry:

快照

This allows us to create regressions with a custom number of inflection points. An inflection point is a point where the graph changes from concave up to concave down or vice versa. The maximum number of inflection points a polynomial can have is the degree - 2. Having multiple inflection points in our regression allows for having a closer fit minimizing error.

It should be noted that having a closer fit is not inherently better; this can cause overfitting. Overfitting is when a model is too closely fit to the training data and not generalizable to the population data.
發布通知
Added a rolling calculation setting for support and resistance lines.
This allows users to have the data period update relative to the live bar. If a new data point enters the data period or the data period moves past an old data point the regression will recalculate.
Bands and Channelsforecastingregressions

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?


Access Flux Charts' exclusive indicators: FluxCharts.com/?via=tv

Join our FREE Discord for live trading sessions, signals, & trading resources: discord.gg/FluxCharts
更多:

免責聲明