OPEN-SOURCE SCRIPT
Long-Term Refuges (LTR)

══════════════════════════════
// Intruduction // (Spanish Texts Below)
══════════════════════════════
This indicator is originally based on a soft fork of the Multi-Timeframe Recursive Zigzag Indicator by ©Trendoscope. We have used the technology of their libraries for Zigzag generation so that the user has the freedom to choose which of the different Zigzags calculated by ©Trendoscope as "Levels" is most suitable for adapting to the generation of ideal phases for evaluation and selection as "most predominant" phases, in long-term periods, for any asset according to its particular behavior based on its volatility and price variation rhythm.
// Theoretical Foundation of the Indicator //
═══════════════════════════════════
Many traditional institutional investors use the last major-grade market phase that stands out
from the others (longer duration and greater price change on daily timeframe), to base a Fibonacci whose levels are used to open long-term positions. These positions can remain open to be activated in the future up to years in advance. The phase is considered valid until a new more predominant phase develops in the future; with which the same strategy is repeated.
// Indicator Objectives
══════════════════
1) Automatically find the last most predominant phase of an asset, analyzing it on daily timeframe and taking into account whether the long-term market trend is bullish or bearish.
2) Plot a Fibonacci Retracement over the predominant phase (reversed if the phase is bullish.)
3) The indicator numbers and locates the 3 most predominant phases, from which it chooses Top-1 for plotting.
4) If the user does not agree with the indicator's automatic selection, they have the freedom to choose any of the other 2 Top phases for plotting the Fibo and its levels.
5) If the user does not agree with the amplitude or frequency of the plotted Zigzag phases, they can modify the parameters of the Zigzag calculation of the ©Trendoscope algorithm until one of the Top-3 matches the phase they have in mind.
6) As an experimental bonus, the indicator runs a contest (CP) of bull's-eye price coincidences (OHLC) daily with all Fibo levels of the selected Top 3 phases, to verify which phase the market prices are validating as the most popular for placing operations. Contest results are displayed in the CP column of the Top-3 phases table. If as a result of the contest it is detected that there is a change in the winning phase, a switch can be enabled to activate an alert that the user can use with TradingView's alert creator to show an alarm, send an email, etc.
7) This indicator was designed for the user to find the long-term predominant phase of their assets and manually record the date-price coordinates of the i0-i1 anchors of the predominant phase. The Top-1 phase coordinates are shown in the table Top-3 phases from where the user can capture them. The date-price coordinates of all HH and LL pivots, of all Zigzag phases, appear through a switch. With the pivots, the user can search or select a different phase from those automatically found
by the indicator, according to their own research. Subsequently, the user forgets about this LTR indicator for a good while and proceeds to apply in their normal operation our SLTR indicator (Simplified Long-Term Refuges), in which they can plot and follow simultaneously the long-term refuges of up to 5 different assets, by just entering their corresponding date-price coordinates,
which were calculated previously with this LTR indicator.
// Additional Notes:
══════════════════
1) As of the publication date of LTR version v1.0 (12/2025), the ©Trendoscope Zigzag generation parameters were adjusted by default to find the long-term predominant phases of Bitcoin and Ethereum (2020-2021 Pandemic). The levels shown in the chart correspond to the results obtained using daily data from Bitstamp exchange, BTCUSD:BITSTAMP (popular in Europe).
2) Due to TradingView's strict publication rules related to the use of languages other than English, the complete Spanish version (plain language), with all entries, help (tooltips) and bibliographic references, will soon be available in our GH repository: aj-poolom-maasewal. Any corrections or improvements that can be made to the phase selection algorithms or to the CP phase contest algorithm, will be highly appreciated (Statistical, mathematical and financial sciences, among many others, are not particularly our forte).
════════════
SPANISH TEXTS
════════════
// Introduccion
════════════
Este indicador esta basado originalmente en un soft fork del Indicador Multi-Timeframe Recursive Zigzag de ©©Trendoscope. Hemos utilizado la tecnologia de sus librerias para la generacion de Zigzags de manera que el usuario tenga la libertad de escoger cual de los diferentes Zigzags que se calculan por ©Trendoscope como "Niveles" es el mas adecuado para adaptarse a la generacion
de las fases ideales para su evaluacion y seleccion como fases "mas preponderantes", en periodos de largo plazo, de cualquier activo de acuerdo a su comportamiento en particular segun su volatibilidad y ritmo de variacion del precio.
// Fundamento Teorico del Indicador
═══════════════════════════
Muchos de los inversores institucionales tradicionales utilizan la ultima fase de mercado de grado mayor que sobresale de las demas (mayor duracion y mayor cambio de precio en temporalidad diaria), para basar un Fibonacci en cuyos niveles abren posiciones de largo plazo. Esas posiciones pueden quedar abiertas para activarse en el futuro hasta con anios de antelacion. Se considera que la fase tiene vigencia hasta que en el futuro se desarrolla otra nueva fase mas preponderante; con la cual
se repite la misma estrategia.
// Objetivos del indicador
════════════════════
1) Encontrar de manera automatica la ultima fase mas preponderante de un activo, analizandolo en temporalidad diaria y tomando en cuenta si la tendencia del mercado a largo plazo es alcista o bajista.
2) Trazar un Retroceso de Fibonacci sobre la fase preponderante (revertido si la fase es alcista.)
3) El indicador numera y localiza las 3 fases mas preponderantes, de las cuales escoge a la Top-1 para el trazado.
4) Si el usuario no concuerda con la seleccion automatica del indicador, tiene la libertad de escoger a cualquiera de las otras 2 fases Top para el trazado del Fibo y sus niveles.
5) Si el usuario no concuerda con la amplitud o la frecuencia de las fases del Zigzag trazado, puede modificar los parametros del calculo del Zigzag del algoritmo de ©Trendoscope hasta que una de las Top-3 coincida con la fase que tiene mentalizada.
6) Como bonus experimental, el indicador ejecuta un concurso (CP) de tiro al blanco de coincidencias de precios (OHLC) diarios, con todos los niveles Fibo de las Top 3 fases seleccionadas, para tratar de comprobar cual es la fase que estan validando los precios del mercado como la mas popular para colocar operaciones. Los resultados del concurso se despliegan en la columna CP de la tabla Top-3 fases. Si como resultado del concurso se detecta que hay un cambio en la fase ganadora, se puede habilitar un switch para que se active una alerta que el usuario puede utilizar con el creador de alertas de Tradingview para que le muestre una alarma, le mande un email, etc.
7) Este indicador fue diseniado para que el usuario encuentre la fase preponderante de largo plazo de sus activos, y registre a mano las coordenadas fecha-precio de las anclas io-i1 de la fase preponderante. Las coordenadas de la fase Top-1 se muestran en la tabla Top-3 fases, de donde la puede capturar el usuario. Las coordenadas fecha-precio de todos los pivots HH y LL, de todas las fases del Zigzag, aparecen mediante un switch. Con los pivots, el usuario puede buscar o seleccionar otra fase diferente a las encontradas automaticamente por el indicador, de acuerdo a su investigacion propia. Posteriormente, el usuario se olvida por un buen rato de este indicador RLP y pasa a aplicar en su operativa normal nuestro indicador RLPS (Refugios de largo plazo simplificado), en el cual puede trazar y dar seguimiento simultaneo a los refugios de largo plazo de hasta 5 diferentes activos, con tan solo introducir sus correspondientes coordenadas fecha-precio, previamente calculadas con este indicador RLP.
// Notas adicionales
════════════════
1) A la fecha de publicacion de la version v1.0 de RLP (LTR) (12/2025), los parametros de generacion del Zigzag de ©Trendoscope se ajustaron por default para encontrar las fases preponderantes de largo plazo de Bitcoin y Etherum (Pandemia 2020-2021). Los niveles mostrados en el grafico, corresponden a los resultados obtenidos, usando los datos diarios del exchange Bitstamp, BTCUSD:BITSTAMP (muy popular aquí en Europa).
2) Debido a las estrictas reglas de publicacion de Tradingview relacionadas con el uso de lenguajes diferentes al ingles, la version en espaniol (roman paladino) completa, con todas las entradas, ayudas (tooltips) y referencias bibliograficas, estara proximamente disponible en nuestro repositorio de GH: aj-poolom-maasewal. Cualquier correccion o mejora que se le puedan hacer a los algoritmos de seleccion de fases o al algoritmo del concurso CP de fases, seran altamente apreciados (La ciencias estadisticas, matematicas y financieras, entre otras muchas, no son particularmente nuestro fuerte).
// Intruduction // (Spanish Texts Below)
══════════════════════════════
This indicator is originally based on a soft fork of the Multi-Timeframe Recursive Zigzag Indicator by ©Trendoscope. We have used the technology of their libraries for Zigzag generation so that the user has the freedom to choose which of the different Zigzags calculated by ©Trendoscope as "Levels" is most suitable for adapting to the generation of ideal phases for evaluation and selection as "most predominant" phases, in long-term periods, for any asset according to its particular behavior based on its volatility and price variation rhythm.
// Theoretical Foundation of the Indicator //
═══════════════════════════════════
Many traditional institutional investors use the last major-grade market phase that stands out
from the others (longer duration and greater price change on daily timeframe), to base a Fibonacci whose levels are used to open long-term positions. These positions can remain open to be activated in the future up to years in advance. The phase is considered valid until a new more predominant phase develops in the future; with which the same strategy is repeated.
// Indicator Objectives
══════════════════
1) Automatically find the last most predominant phase of an asset, analyzing it on daily timeframe and taking into account whether the long-term market trend is bullish or bearish.
2) Plot a Fibonacci Retracement over the predominant phase (reversed if the phase is bullish.)
3) The indicator numbers and locates the 3 most predominant phases, from which it chooses Top-1 for plotting.
4) If the user does not agree with the indicator's automatic selection, they have the freedom to choose any of the other 2 Top phases for plotting the Fibo and its levels.
5) If the user does not agree with the amplitude or frequency of the plotted Zigzag phases, they can modify the parameters of the Zigzag calculation of the ©Trendoscope algorithm until one of the Top-3 matches the phase they have in mind.
6) As an experimental bonus, the indicator runs a contest (CP) of bull's-eye price coincidences (OHLC) daily with all Fibo levels of the selected Top 3 phases, to verify which phase the market prices are validating as the most popular for placing operations. Contest results are displayed in the CP column of the Top-3 phases table. If as a result of the contest it is detected that there is a change in the winning phase, a switch can be enabled to activate an alert that the user can use with TradingView's alert creator to show an alarm, send an email, etc.
7) This indicator was designed for the user to find the long-term predominant phase of their assets and manually record the date-price coordinates of the i0-i1 anchors of the predominant phase. The Top-1 phase coordinates are shown in the table Top-3 phases from where the user can capture them. The date-price coordinates of all HH and LL pivots, of all Zigzag phases, appear through a switch. With the pivots, the user can search or select a different phase from those automatically found
by the indicator, according to their own research. Subsequently, the user forgets about this LTR indicator for a good while and proceeds to apply in their normal operation our SLTR indicator (Simplified Long-Term Refuges), in which they can plot and follow simultaneously the long-term refuges of up to 5 different assets, by just entering their corresponding date-price coordinates,
which were calculated previously with this LTR indicator.
// Additional Notes:
══════════════════
1) As of the publication date of LTR version v1.0 (12/2025), the ©Trendoscope Zigzag generation parameters were adjusted by default to find the long-term predominant phases of Bitcoin and Ethereum (2020-2021 Pandemic). The levels shown in the chart correspond to the results obtained using daily data from Bitstamp exchange, BTCUSD:BITSTAMP (popular in Europe).
2) Due to TradingView's strict publication rules related to the use of languages other than English, the complete Spanish version (plain language), with all entries, help (tooltips) and bibliographic references, will soon be available in our GH repository: aj-poolom-maasewal. Any corrections or improvements that can be made to the phase selection algorithms or to the CP phase contest algorithm, will be highly appreciated (Statistical, mathematical and financial sciences, among many others, are not particularly our forte).
════════════
SPANISH TEXTS
════════════
// Introduccion
════════════
Este indicador esta basado originalmente en un soft fork del Indicador Multi-Timeframe Recursive Zigzag de ©©Trendoscope. Hemos utilizado la tecnologia de sus librerias para la generacion de Zigzags de manera que el usuario tenga la libertad de escoger cual de los diferentes Zigzags que se calculan por ©Trendoscope como "Niveles" es el mas adecuado para adaptarse a la generacion
de las fases ideales para su evaluacion y seleccion como fases "mas preponderantes", en periodos de largo plazo, de cualquier activo de acuerdo a su comportamiento en particular segun su volatibilidad y ritmo de variacion del precio.
// Fundamento Teorico del Indicador
═══════════════════════════
Muchos de los inversores institucionales tradicionales utilizan la ultima fase de mercado de grado mayor que sobresale de las demas (mayor duracion y mayor cambio de precio en temporalidad diaria), para basar un Fibonacci en cuyos niveles abren posiciones de largo plazo. Esas posiciones pueden quedar abiertas para activarse en el futuro hasta con anios de antelacion. Se considera que la fase tiene vigencia hasta que en el futuro se desarrolla otra nueva fase mas preponderante; con la cual
se repite la misma estrategia.
// Objetivos del indicador
════════════════════
1) Encontrar de manera automatica la ultima fase mas preponderante de un activo, analizandolo en temporalidad diaria y tomando en cuenta si la tendencia del mercado a largo plazo es alcista o bajista.
2) Trazar un Retroceso de Fibonacci sobre la fase preponderante (revertido si la fase es alcista.)
3) El indicador numera y localiza las 3 fases mas preponderantes, de las cuales escoge a la Top-1 para el trazado.
4) Si el usuario no concuerda con la seleccion automatica del indicador, tiene la libertad de escoger a cualquiera de las otras 2 fases Top para el trazado del Fibo y sus niveles.
5) Si el usuario no concuerda con la amplitud o la frecuencia de las fases del Zigzag trazado, puede modificar los parametros del calculo del Zigzag del algoritmo de ©Trendoscope hasta que una de las Top-3 coincida con la fase que tiene mentalizada.
6) Como bonus experimental, el indicador ejecuta un concurso (CP) de tiro al blanco de coincidencias de precios (OHLC) diarios, con todos los niveles Fibo de las Top 3 fases seleccionadas, para tratar de comprobar cual es la fase que estan validando los precios del mercado como la mas popular para colocar operaciones. Los resultados del concurso se despliegan en la columna CP de la tabla Top-3 fases. Si como resultado del concurso se detecta que hay un cambio en la fase ganadora, se puede habilitar un switch para que se active una alerta que el usuario puede utilizar con el creador de alertas de Tradingview para que le muestre una alarma, le mande un email, etc.
7) Este indicador fue diseniado para que el usuario encuentre la fase preponderante de largo plazo de sus activos, y registre a mano las coordenadas fecha-precio de las anclas io-i1 de la fase preponderante. Las coordenadas de la fase Top-1 se muestran en la tabla Top-3 fases, de donde la puede capturar el usuario. Las coordenadas fecha-precio de todos los pivots HH y LL, de todas las fases del Zigzag, aparecen mediante un switch. Con los pivots, el usuario puede buscar o seleccionar otra fase diferente a las encontradas automaticamente por el indicador, de acuerdo a su investigacion propia. Posteriormente, el usuario se olvida por un buen rato de este indicador RLP y pasa a aplicar en su operativa normal nuestro indicador RLPS (Refugios de largo plazo simplificado), en el cual puede trazar y dar seguimiento simultaneo a los refugios de largo plazo de hasta 5 diferentes activos, con tan solo introducir sus correspondientes coordenadas fecha-precio, previamente calculadas con este indicador RLP.
// Notas adicionales
════════════════
1) A la fecha de publicacion de la version v1.0 de RLP (LTR) (12/2025), los parametros de generacion del Zigzag de ©Trendoscope se ajustaron por default para encontrar las fases preponderantes de largo plazo de Bitcoin y Etherum (Pandemia 2020-2021). Los niveles mostrados en el grafico, corresponden a los resultados obtenidos, usando los datos diarios del exchange Bitstamp, BTCUSD:BITSTAMP (muy popular aquí en Europa).
2) Debido a las estrictas reglas de publicacion de Tradingview relacionadas con el uso de lenguajes diferentes al ingles, la version en espaniol (roman paladino) completa, con todas las entradas, ayudas (tooltips) y referencias bibliograficas, estara proximamente disponible en nuestro repositorio de GH: aj-poolom-maasewal. Cualquier correccion o mejora que se le puedan hacer a los algoritmos de seleccion de fases o al algoritmo del concurso CP de fases, seran altamente apreciados (La ciencias estadisticas, matematicas y financieras, entre otras muchas, no son particularmente nuestro fuerte).
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.