OPEN-SOURCE SCRIPT

Moving Average Resting Point [theEccentricTrader]

█  OVERVIEW


This indicator uses peak and trough prices to calculate the moving average resting point and plots it as a line on the chart. The lookback length is variable and the indicator can plot up to three lines with different lookback lengths and colors.


█  CONCEPTS


Green and Red Candles

• A green candle is one that closes with a high price equal to or above the price it opened.
• A red candle is one that closes with a low price that is lower than the price it opened.

Swing Highs and Swing Lows

• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.

Peak and Trough Prices (Basic)

• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.

Historic Peaks and Troughs

The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.

Support and Resistance

• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.

Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.

It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.

Wave Cycles

A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. As can be seen in the example above, the first swing high or swing low will set the course for the sequence of wave cycles that follow; a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.

Wave Length

Wave length is here measured in terms of bar distance between the start and end of a wave cycle. For example, if the current wave cycle ends on a swing low the wave length will be the difference in bars between the current swing low and current swing high. In such a case, if the current swing low completes on candle 100 and the current swing high completed on candle 95, we would simply subtract 95 from 100 to give us a wave length of 5 bars.

Average wave length is here measured in terms of total bars as a proportion as total waves. The average wavelength is calculated by dividing the total candles by the total wave cycles.

Wave Height

Wave height is here measured in terms of current range. For example, if the current peak price is 100 and the current trough price is 80, the wave height will be 20.

Amplitude

Amplitude is here measured in terms of current range divided by two. For example if the current peak price is 100 and the current trough price is 80, the amplitude would be calculated by subtracting 80 from 100 and dividing the answer by 2 to give us an amplitude of 10.

Resting Point

The resting point is here calculated by subtracting the current trough price from the current peak price and adding the difference to the current trough price to output the price in the middle of the two prices. Essentially it is the current trough price plus the amplitude. For example, if the current peak price is 100 and the current trough price is 80, the resting point 90.

The moving average resting point is here calculated by subtracting the moving average trough price from the moving average peak price, dividing the answer by two and adding the difference to the moving average trough price.

Frequency

Frequency is here measured in terms of wave cycles per second (Hertz). For example, if the total wave cycle count is 10 and the amount of time it has taken to complete these 10 cycles is 1-year (31,536,000 seconds), the frequency would be calculated by dividing 10 by 31,536,000 to give us a frequency of 0.00000032 Hz.

Range

The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.


█  FEATURES


Inputs

Show MARP 1
Show MARP 2
Show MARP 3
MARP 1 Length
MARP 2 Length
MARP 3 Length
MARP 1 Color
MARP 2 Color
MARP 3 Color


█  HOW TO USE


This indicator can be used like any other moving average indicator to analyse trend direction and momentum, identify potential support and resistance levels, or for filtering trading strategies and developing new ones.
Moving AveragesTrend AnalysisWave Analysis

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明