BreezeTrades808

Two MAs (nextSignals)

Hi folks, just some quick work inspired by ThinkScript code from @stephenharlinmd (the Doc).

This indicator seems to be intended for lower timeframes (3 min was used for example), and indicates long and short opportunities based on crossovers of the two lines.

The slow reference line is an EMA20. The fast line is referred to as an "Instantaneous Moving Average", which attempts to use OHLC4 values to create a realtime reference line for price instead of a lagging average. Its calculation is as follows:

1. The OHLC4 value is calculated by taking the average of the open, high, low, and close prices for each bar.

2. The ta.highest function is used to find the highest value of OHLC4 over the last 5 bars, and this value is stored in the ON variable.

3. The ta.lowest function is used to find the lowest value of ON over the last 5 bars, and this value is stored in the O1 variable.

4. The for loop is used to find the index of O1 in the P data series, which represents the OHLC4 values over the last 6 bars. If the value at the current index is equal to O1, and O1Loc has not already been set, then O1Loc is set to the current index.

5. The O2 variable is initialized to ON, and another for loop is used to find the index of the second lowest value of OHLC4 over the last 6 bars, which is not at the same index as O1. If the value at the current index is equal to O2, and O2Loc has not already been set, and the current index is not equal to O1Loc, then O2Loc is set to the current index.

6. The O3 variable is initialized to ON, and another for loop is used to find the minimum value of OHLC4 over the last 6 bars, excluding the values at the indices of O1 and O2. If the current index is not equal to O1Loc or O2Loc, then the minimum of the current value of O3 and the value at the current index of P is stored in O3.

7. Finally, the "IMA" variable is set to the value of O3, which represents the "IMA" over the last 6 bars.

Script de código abierto

Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.

¿Quiere utilizar este script en un gráfico?