PROTECTED SOURCE SCRIPT
Trend Lines by CR86

The basic construction algorithm:
1. The baseline trend line through the closing prices:
First, the best fit line (linear regression) is calculated for the closing prices for a given period.
The least squares method is used to find the optimal slope and intersection point.
2. Search for key deviation points:
For each bar in the period, the deviation of the maximum and minimum from the regression baseline is calculated.
The point with the maximum deviation of the maximum upward from the regression line (for the resistance line) is located
The point with the maximum deviation of the minimum is located down from the regression line (for the support line)
3. Optimizing the slope of the lines:
Lines with an optimized slope are drawn through the found key points.
The algorithm selects the slope so that the line best "bends around" the corresponding extremes (maxima for resistance, minima for support)
Numerical optimization is used to check the validity of the trend line.
4. The principle of validity:
For the support line: all points must be above or at the line level (with a tolerance of 1e-5)
For the resistance line: all points must be below or at the line level (with a tolerance of 1e-5)
Key Features
Adaptability: the lines automatically adjust to the actual price extremes
Mathematical precision: a rigorous mathematical approach with optimization is used
Logarithmic scaling: optional for dealing with highly volatile assets
The basic construction algorithm
1. The baseline trend line through the closing prices:
First, the best fit line (linear regression) is calculated for the closing prices for a given period.
The least squares method is used to find the optimal slope and intersection point.
2. Search for key deviation points:
For each bar in the period, the deviation of the maximum and minimum from the regression baseline is calculated.
The point with the maximum deviation of the maximum upward from the regression line (for the resistance line) is located
The point with the maximum deviation of the minimum is located down from the regression line (for the support line)
3. Optimizing the slope of the lines:
Lines with an optimized slope are drawn through the found key points.
The algorithm selects the slope so that the line best "bends around" the corresponding extremes (maxima for resistance, minima for support)
Numerical optimization is used to check the validity of the trend line.
4. The principle of validity:
For the support line: all points must be above or at the line level (with a tolerance of 1e-5)
For the resistance line: all points must be below or at the line level (with a tolerance of 1e-5)
Key Features
Adaptability: the lines automatically adjust to the actual price extremes
Mathematical precision: a rigorous mathematical approach with optimization is used
Logarithmic scaling: optional for dealing with highly volatile assets
***********************************************************************************************
Основной алгоритм построения:
1. Базовая линия тренда через цены закрытия:
Сначала вычисляется линия наилучшего соответствия (линейная регрессия) для цен закрытия за заданный период
Используется метод наименьших квадратов для нахождения оптимального наклона и точки пересечения
2. Поиск ключевых точек отклонения:
Для каждого бара в периоде вычисляется отклонение максимума и минимума от базовой линии регрессии
Находится точка с максимальным отклонением максимума вверх от линии регрессии (для линии сопротивления)
Находится точка с максимальным отклонением минимума вниз от линии регрессии (для линии поддержки)
3. Оптимизация наклона линий:
Через найденные ключевые точки проводятся линии с оптимизированным наклоном
Алгоритм подбирает такой наклон, чтобы линия наилучшим образом "огибала" соответствующие экстремумы (максимумы для сопротивления, минимумы для поддержки)
Используется численная оптимизация с проверкой валидности трендовой линии
4. Принцип валидности:
Для линии поддержки: все точки должны быть выше или на уровне линии (с допуском 1e-5)
Для линии сопротивления: все точки должны быть ниже или на уровне линии (с допуском 1e-5)
Ключевые особенности
Адаптивность: линии автоматически подстраиваются под фактические экстремумы цен
Математическая точность: используется строгий математический подход с оптимизацией
Логарифмическое масштабирование: опционально для работы с сильно волатильными активами
1. The baseline trend line through the closing prices:
First, the best fit line (linear regression) is calculated for the closing prices for a given period.
The least squares method is used to find the optimal slope and intersection point.
2. Search for key deviation points:
For each bar in the period, the deviation of the maximum and minimum from the regression baseline is calculated.
The point with the maximum deviation of the maximum upward from the regression line (for the resistance line) is located
The point with the maximum deviation of the minimum is located down from the regression line (for the support line)
3. Optimizing the slope of the lines:
Lines with an optimized slope are drawn through the found key points.
The algorithm selects the slope so that the line best "bends around" the corresponding extremes (maxima for resistance, minima for support)
Numerical optimization is used to check the validity of the trend line.
4. The principle of validity:
For the support line: all points must be above or at the line level (with a tolerance of 1e-5)
For the resistance line: all points must be below or at the line level (with a tolerance of 1e-5)
Key Features
Adaptability: the lines automatically adjust to the actual price extremes
Mathematical precision: a rigorous mathematical approach with optimization is used
Logarithmic scaling: optional for dealing with highly volatile assets
The basic construction algorithm
1. The baseline trend line through the closing prices:
First, the best fit line (linear regression) is calculated for the closing prices for a given period.
The least squares method is used to find the optimal slope and intersection point.
2. Search for key deviation points:
For each bar in the period, the deviation of the maximum and minimum from the regression baseline is calculated.
The point with the maximum deviation of the maximum upward from the regression line (for the resistance line) is located
The point with the maximum deviation of the minimum is located down from the regression line (for the support line)
3. Optimizing the slope of the lines:
Lines with an optimized slope are drawn through the found key points.
The algorithm selects the slope so that the line best "bends around" the corresponding extremes (maxima for resistance, minima for support)
Numerical optimization is used to check the validity of the trend line.
4. The principle of validity:
For the support line: all points must be above or at the line level (with a tolerance of 1e-5)
For the resistance line: all points must be below or at the line level (with a tolerance of 1e-5)
Key Features
Adaptability: the lines automatically adjust to the actual price extremes
Mathematical precision: a rigorous mathematical approach with optimization is used
Logarithmic scaling: optional for dealing with highly volatile assets
***********************************************************************************************
Основной алгоритм построения:
1. Базовая линия тренда через цены закрытия:
Сначала вычисляется линия наилучшего соответствия (линейная регрессия) для цен закрытия за заданный период
Используется метод наименьших квадратов для нахождения оптимального наклона и точки пересечения
2. Поиск ключевых точек отклонения:
Для каждого бара в периоде вычисляется отклонение максимума и минимума от базовой линии регрессии
Находится точка с максимальным отклонением максимума вверх от линии регрессии (для линии сопротивления)
Находится точка с максимальным отклонением минимума вниз от линии регрессии (для линии поддержки)
3. Оптимизация наклона линий:
Через найденные ключевые точки проводятся линии с оптимизированным наклоном
Алгоритм подбирает такой наклон, чтобы линия наилучшим образом "огибала" соответствующие экстремумы (максимумы для сопротивления, минимумы для поддержки)
Используется численная оптимизация с проверкой валидности трендовой линии
4. Принцип валидности:
Для линии поддержки: все точки должны быть выше или на уровне линии (с допуском 1e-5)
Для линии сопротивления: все точки должны быть ниже или на уровне линии (с допуском 1e-5)
Ключевые особенности
Адаптивность: линии автоматически подстраиваются под фактические экстремумы цен
Математическая точность: используется строгий математический подход с оптимизацией
Логарифмическое масштабирование: опционально для работы с сильно волатильными активами
Skrip dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya dengan percuma dan tanpa had – ketahui lebih lanjut di sini.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya dengan percuma dan tanpa had – ketahui lebih lanjut di sini.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.