OPEN-SOURCE SCRIPT

Gaussian SWMA For Loop

От Coff3eG
Gaussian SWMA For Loop Indicator
The "Gaussian SWMA For Loop" is a sophisticated indicator designed to identify potential trading opportunities by combining a Gaussian-weighted moving average (WMA) with a simple moving average (SMA), enhanced by a loop-based scoring system. This indicator is tailored for traders looking to capture trends and reversals with a refined approach, making use of advanced filtering techniques and custom thresholds for signal generation.

Key Features:
1. Gaussian Weighted Moving Average (WMA):
  • The indicator starts by applying a Gaussian filter to the input price data (default is the closing price). The Gaussian filter smooths the data by applying weights according to a Gaussian distribution, determined by the Gaussian Sigma parameter. This results in a smooth, noise-reduced WMA, which is more responsive to significant price movements while ignoring minor fluctuations.


2. Simple Moving Average (SMA) on Smoothed Data:
  • After the data is smoothed using the Gaussian filter, an SMA is calculated over this smoothed data. The length of this SMA can be adjusted via the SMA Length input, allowing users to control the level of additional smoothing applied to the already filtered data.


3. Loop-Based Scoring System:
  • Range Analysis: The core feature of this indicator is the loop-based scoring system. It evaluates the filtered SMA by comparing its current value to previous values over a specified range, defined by the From and To parameters.
  • Score Calculation: The loop iterates through each value within the defined range and adjusts a score based on whether the current filtered SMA is higher or lower than its historical values. This score is a measure of the trend's strength and direction.
  • Thresholds for Signal Generation: Users can define custom thresholds for long (Long Threshold) and short (Short Threshold) signals. The score is compared against these thresholds to generate buy and sell signals.


4. Signal Generation:
  • Buy Signal (L): Triggered when the score exceeds the user-defined Long Threshold.
  • Sell Signal (S): Triggered when the score falls below the Short Threshold.


5. Visual Enhancements:
The indicator plots the filtered SMA on the chart, with the line and bar colors changing based on the buy and sell signals:
  • Teal (color.rgb(0, 255, 187)) for a buy signal.
  • Magenta (color.rgb(255, 0, 157)) for a sell signal.
  • Gray for a neutral condition.

Additionally, the fill between the current and previous SMA values is colored based on the signal, providing a clear visual cue for trend direction and strength.

6. Alert Conditions:
The indicator includes customizable alerts that notify the user when a buy or sell signal is generated:
  • Long Alert: Notifies when a buy signal is triggered.
  • Short Alert: Notifies when a sell signal is triggered.



Configurable Inputs:
Main Group:
  • WMA Length (length): Sets the length of the Gaussian-weighted moving average.
  • SMA Length (len): Specifies the period for the SMA applied to the Gaussian-smoothed data.
  • Source (src): The price data used for calculations (default is the closing price).
  • Gaussian Sigma (sigma): Determines the standard deviation of the Gaussian distribution, influencing the smoothing effect.


For Loop Group:
  • From (a): The starting point for the loop-based score analysis.
  • To (b): The endpoint for the loop-based score analysis.


Threshold Group:
  • Long Threshold (threshold_L): Defines the score threshold above which a buy signal is triggered.
  • Short Threshold (threshold_S): Defines the score threshold below which a sell signal is triggered.



Practical Use:
This indicator is ideal for traders who want to identify trends and potential reversals with precision. The combination of Gaussian smoothing, SMA, and the loop-based scoring system offers a robust method to filter out noise and focus on significant market moves. The customizable thresholds and alert system further enhance its utility, making it a powerful tool for both manual and automated trading strategies.

Note: As with any trading indicator, it's recommended to backtest the "Gaussian SWMA For Loop" under various market conditions and use it in conjunction with other analysis techniques to confirm signals before making trading decisions.
Simple Moving Average (SMA)Trend AnalysisWeighted Moving Average (WMA)
Coff3eG

Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Хотите использовать этот скрипт на графике?

Отказ от ответственности