TradingView
PineCodersTASC
13 אוק׳ 2022 23:25

TASC 2022.11 Phasor Analysis 

S&P 500SP

תיאור

█ OVERVIEW

TASC's November 2022 edition Traders' Tips includes an article by John ​Ehlers titled "Recurring Phase Of Cycle Analysis". This is the code that implements the ​phasor analysis indicator presented in this publication.


█ CONCEPTS

The article explores the use of phasor analysis to identify market trends.

An ordinary rotating phasor diagram is a two-dimensional vector, anchored to the origin, whose rotation rate corresponds to the cycle period in the price data stream. Similarly, Ehlers' phasor is a representation of angular phase rotation along the course of time. Its angle reflects the current phase of the cycle. Angles -180, -90, +90 and +180 degrees correspond to the beginning, valley, peak and end of the cycle, respectively.

If the observed cycle is very long, the market can be considered trending. In his article, John ​Ehlers defined trending behavior to occur when the derived instantaneous cycle period value is greater that 60 bars. The author also introduced guidelines for long and short entries in a trending state. Depending on the tuning of the indicator period input, a long entry position may occur when the phasor angle is around the approximate vicinity of −90 degrees, while a short entry position may occur when the phasor angle will be around the approximate vicinity of +90 degrees. Applying these definitive guidelines, the author proposed a state variable that is indicated by +1 for a trending long position, 0 for cycling, and −1 for a trending short position (or out).

The phasor angle, the cycle period, and the state variable are made available with three selectable display modes provided for this TradingView indicator.

█ CALCULATIONS

The calculations are carried out as follows.

First, the price data stream is correlated with cosine and sine of a fixed cycle period. This produces two new data streams that correspond to the projections of the frequency domain phasor diagram to the horizontal (so-called real) and vertical (so-called imaginary) axis respectively. The wavelength of the cycle period input should be set for the midrange vicinities of the phasor to coincide with the peaks and valleys of the charted price data.

Secondly, the phase angle of the phasor is easily computed as the arctangent of the ratio of the imaginary component to the real component. The difference between the current phasor values and its last is then employed to calculate a derived instantaneous period and market state. This computation is then repeated successively for each individual bar over the entire duration of the data set.
תגובות
peacefulLizard50262
Very cool!
theheirophant
Thanks Midtown, can tell your gfx effects style anywhere. Keep up the great work bro
veryfid
Thanks!
tyler8910
Seems to do a horrific job of catching uptrends, but thanks.
PineCodersTASC
@tyler8910, Hi, in principle, any of the three available output options ("Angle", "Period", "State") are intended to be applicable for detecting uptrends. For example, in the "Angle" mode shown in the preview chart, uptrends are identified as straight horizontal lines below the 0.0 level. (See the region between June 2021 and September 2021.) Similarly, downtrends show up as horizontal lines above 0.0. More information about the use of this indicator and phasor analysis in general can be found in the original TASC article.
allanster
Beautiful, thanks!
danemm
Great indicator! Thanks for sharing! If you happen to do requests, I haven't been able to find GFI anywhere
עוד