Using Maps collections:

This code manipulates support and resistance lines using maps collection.
We normally maintain array/udt of lines and related properties to segregate lines as support and or resistance.

With introduction of maps the same can be achieved without creating lines array/udt.

What does this code do:
1. Plot support and resistance lines based on ta.pivothigh() and ta.pivotlow()
2. When price crosses support line, the line is marked as resistance and color is changed to resistance line color and style is changed to dotted line (support turned resistance). Also the width of the line is set based on number of crosses. Finally the support/resistance line is removed when number of times price crossing the line reaches max allowed crosses (input parameter)

Where maps are used:
1. map_sr_cross - Number of times the support/resistance lines has been crossed by price
2. map_sr_type - R=resistance, S=support
3. color_map - color for support and resistance lines
4. style_map - line styles. Support/resistance lines as solid style and support turned resistance/resistance turned support lines as dotted style.



Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?