OPEN-SOURCE SCRIPT

Gaussian Weighted Moving Average with Forecast [CHE]

已更新
Presentation for TradingView: Gaussian Weighted Moving Average with Forecast

Introduction

Welcome to our presentation on the "Gaussian Weighted Moving Average with Forecast" (GWMA). This script, written in Pine Script™, offers an enhanced method for analyzing and predicting price movements on TradingView. The script combines Gaussian Weighted Moving Averages and polynomial regression to provide accurate and customizable forecasts.

Overview

Title: Gaussian Weighted Moving Average with Forecast
Author: chervolino
License: Mozilla Public License 2.0

Main Features

1. Gaussian Weighted Moving Average (GWMA):
- Calculates a weighted moving average using a Gaussian weighting function.
- Parameters for length and standard deviation allow fine-tuning of the smoothing effect.

2. Polynomial Regression with Forecast:
- Creates a model to predict future price movements.
- Adjustable length and degree of polynomial regression.
- Option to extrapolate predictions and visualize them.

3. Visual Representation:
- Uses lines and colors to depict trend changes.
- Customizable colors for upward and downward trends.

Input Parameters

Length: Length of the moving average (default: 50)
Standard Deviation: Standard deviation for Gaussian weighting (default: 10.0)
Width: Width of the plotted lines (default: 1)
Colors: Customizable colors for upward and downward trends
Forecast Length: Length of the forecast period (default: 20)
Extrapolate Length: Length of the extrapolation (default: 50)
Polynomial Degree: Degree of the polynomial regression (default: 3)
Lock Forecast: Option to lock and stabilize the forecast

Core Algorithms

1. Gaussian Weight Calculation:
gaussian_weight(x, std_dev) =>
1 / (std_dev * math.sqrt(2 * math.pi)) * math.exp(-0.5 * math.pow(x / std_dev, 2))

2. GWMA Calculation:
calculate_gwma(length, std_dev) =>
// Algorithm to calculate the weighted moving average

3. Initialize Lines for Polynomial Regression:
initialize_lines_array(extrapolate, length) =>
// Initialize array lines

4. Create Design Matrix for Polynomial Regression:
get_design_matrix(length, degree) =>
// Create the design matrix

5. Calculate and Plot Polynomial Regression:
calculate_polynomial_regression(src, length, degree, extrapolate, lines_arr, lock, width, upward_color, downward_color) =>
// Algorithm to calculate polynomial regression and plot the forecast

Combining Indicators: Originality and Usefulness

The combination of Gaussian Weighted Moving Average and polynomial regression provides traders with a robust tool for trend analysis and prediction. The GWMA smooths out price data while emphasizing recent prices, making it sensitive to short-term trends. Polynomial regression, on the other hand, offers a mathematical approach to model and forecast future prices based on historical data. By integrating these two methodologies, traders can achieve a more comprehensive view of market trends and potential future movements, making the tool highly valuable for decision-making.

Explanation for Users

Most TradingView users are not familiar with Pine Script, so a clear description is essential for understanding how to use the script.

Gaussian Weighted Moving Average (GWMA): This indicator calculates a moving average using Gaussian weights, which gives more importance to recent prices. The length and standard deviation parameters allow users to control the sensitivity and smoothness of the average.

Polynomial Regression with Forecast: This feature uses polynomial regression to model the price trend and predict future movements. Users can adjust the length of the historical data used, the degree of the polynomial, and the length of the forecast. The script plots these predictions, making it easier for traders to visualize potential future price paths.

Visualization of Results

1. GWMA Plotting:
plot(gaussian_ma_result, title="GWMA", color=line_color, linewidth=width_input)

2. Forecast Extrapolation:
plot(forecast_val, 'Extrapolation', offset=extrapolate_setting, linewidth=width_input, style=plot.style_circles)

Conclusion

The "Gaussian Weighted Moving Average with Forecast" script provides a powerful tool for analyzing and predicting price movements on TradingView. By combining Gaussian weighting and polynomial regression, it offers a precise and customizable method for trend analysis and forecasting.

Thank you for your attention! For any questions or further information, please feel free to reach out.
發行說明
Delete the plot function
Chart patternsCycles

開源腳本

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

想在圖表上使用此腳本?

免責聲明