Custom Trading Scripts

Your Online Source For Stock Codes

CTS Moving Average Average Trend Line Study


This script is designed to create a custom moving average average trend line, and it includes various stop lines and lines to indicate potential price levels.

1. Inputs:
– `BarsForTrend`: Number of bars to consider for trend comparison.
– `Percent1`, `Percent2`, `Percent3`: Percentage values for calculations.
– Other inputs for various moving averages.

2. Calculating Moving Averages:
– Calculates different types of moving averages (EMA and SMA) based on the provided input parameters.

3. Calculating Moving Average Average (MovAvgAvg):
– Computes the average of various moving averages (EMA8, EMA21, EMA34, SMA50, SMA100, SMA200) to get the “Moving Average Average.”

4. Determining Up and Down Trends:
– Determines if the current trend is an uptrend or downtrend by comparing the current “Moving Average Average” with its value from a certain number of bars ago.

5. Defining Stop Lines:
– Calculates upper and lower stop lines based on percentage deviations from the “Moving Average Average.”

6. Plotting and Visualization:
– Plots the “Moving Average Average” as a line chart.
– Assigns color and line weight based on whether it’s an uptrend or downtrend.
– Plots upper and lower stop lines, as well as additional lines with certain percentage deviations from the “Moving Average Average,” and assigns colors and line weights accordingly.

This script creates a trend line based on an average of multiple moving averages. It also plots various lines to indicate potential support and resistance levels based on percentage deviations from the moving average. The color and line weight of each plotted line change based on the current trend direction. This tool can help traders visualize potential trends and price levels on their charts.

Please note that this script is for educational purposes and cannot be shared due to user agreement restrictions.