PineCodersTASC

TASC 2022.11 Phasor Analysis

█ 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.

Tools and ideas for all Pine coders: www.tradingview.com/u/PineCoders/
Pine news broadcasts: t.me/PineCodersSquawkBox or twitter.com/PineCoders
TASC: traders.com/
Script open-source

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzarlo gratuitamente, ma il riutilizzo del codice è subordinato al rispetto del Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questo script sui tuoi grafici?