Zen

The Theory of Entanglement (缠论) is one of the most widely studied trading theories in China, but it is much less known among traders outside. Its philosophy is based on human greed, hatred, delusion, arrogance and doubt, which reveal the most fundamental aspect of the market. Fractals, strokes, line segments and pivots are basic elements in the Theory of Entanglement. However, manually drawing them on an ever-changing chart is both challenging and time consuming, and may lead to incorrect interpretation of the market trend. This indicator aims to automate the process of drawing strokes, line segments, and pivots for three consecutive levels such as 1m, 5m, and 30m (similar to time frames). The operation is then based on the so-called “same-level decomposition” technique. Buying and selling points are automatically marked on the chart, as well as points where trend divergence and range divergence occurred, which often signals a trend reversal.

Relations between fractal , stroke, line segment, pivot , and some important definitions:
• Stroke: Connecting two adjacent top and bottom fractals with at least one candlestick in between.
• Line segment: Consists of an odd number of strokes, at least three strokes are required, and the first three strokes must have overlapping parts.
• Level: Levels generally correspond to time frames of the chart, such as 1w, 1d, 4h, 30m, 5m, 1m etc. Sub-level: The above levels are respectively the sub-levels of the previous level.
• Pivot: The part of a trend type at a certain level that is overlapped by at least three consecutive sub-level trend types.
• Trend type: There are two trend types: trend and range. In trend, there are also two types: rising trend and falling trend.
• Range: At any level, a completed trend type contains only one pivot .
• Trend: At any level, a completed trend type contains at least two pivots in the same direction in sequence, which is called a trend at this level.

List of drawings on the chart:
1. Thin black lines: Strokes at the current level.
2. Thick blue lines: Strokes at a higher level, also line segments at the current level.
3. Purple dotted lines: Line segments at a higher level, also strokes at two levels higher from the current one.
4. Blue shaded rectangles: Pivots at the sub-level in a rising trend or range.
5. Red shaded rectangles: Pivots at the sub-level in a falling trend or range.
6. Green shaded rectangles: Pivots at the current level in a rising trend or range.
7. Orange shaded rectangles: Pivots at the current level in a falling trend or range.

List of symbols and labels on the chart (above the candle: sell signal, below the candle: buy signal)
1. Purple triangles below the candle: double golden cross of Stochastic and MACD , buy signal
2. Purple triangles above the candle: double death cross of Stochastic and MACD , sell signal
3. Blue triangles below the candle: EMA5 crosses EMA13 up, buy signal
4. Red triangles above the candle: EMA5 crosses EMA13 down, sell signal
5. Green triangles below the candle: EMA5 crosses EMA55 up, buy signal
6. Orange triangles above the candle: EMA5 crosses EMA55 down, sell signal
7. Blue circles on the low point of the candle: bottom divergence occurred, buy signal
8. Red circles on the high point of the candle: top divergence occurred, sell signal
9. Blue "R" label below the candle: bottom divergence calculated from RSI occurred, buy signal
10. Red "R" label above the candle: top divergence calculated from RSI occurred, sell signal
11. Blue "M" label below the candle: bottom divergence calculated from MACD occurred, buy signal
12. Red "M" label above the candle: top divergence calculated from MACD occurred, sell signal
13. Blue "RM" label below the candle: bottom divergence calculated from both RSI and MACD occurred, buy signal
14. Red "RM" label above the candle: top divergence calculated from both RSI and MACD occurred, sell signal
15. Blue "1(R)", "1(M)", "1( RM )" labels below the candle: 1st buying point due to bottom trend divergence or range divergence calculated from RSI , MACD , and both RSI and MACD occurred, respectively, buy signal
16. Red "1(R)", "1(M)", "1( RM )" labels above the candle: 1st selling point due to top trend divergence or range divergence calculated from RSI , MACD , and both RSI and MACD occurred, respectively, sell signal
17. Blue "3" label below the candle: 3rd buying point, buy signal
18. Red "3" label above the candle: 3rd selling point, sell signal
19. Green "3" label below the candle: 3rd buying point of a higher-level pivot , buy signal
20. Orange "3" label above the candle: 3rd selling point of a higher-level pivot , sell signal
21. Yellow-shaded vertical areas: candles where volume spikes occurred
22. Short red horizontal lines: highest point of volume spikes, potential support or resistance
23. Short blue horizontal lines: lowest point of volume spikes, potential support or resistance

• For golden crosses (triangle symbols under candles), choose Zen -> Cross Up -> Less Than -> Value -> 0.00
• For death crosses (triangle symbols above candles), choose Zen -> Cross Down -> Greater Than -> Value -> 0.00
• For buying points (blue “R”, “M”, “RM”, “1(R)”, “1(M)”, “1(RM)”, and “3” labels), choose Zen -> Buying Point -> Less Than -> Zen -> Reference Point
• For selling points (red “R”, “M”, “RM”, “1(R)”, “1(M)”, “1(RM)”, and “3” labels), choose Zen -> Selling Point -> Greater Than -> Zen -> Reference Point

2. Added colors for bullish/bearish outside strokes and bullish/bearish outside line segments
• For bullish outside stroke, choose Zen -> Outside Stroke/Line Segment -> Inside Channel -> (Upper Bound) Value -> -5.00 -> (Lower Bound) Value -> -15.00
• For bearish outside stroke, choose Zen -> Outside Stroke/Line Segment -> Inside Channel -> (Upper Bound) Value -> 15.00 -> (Lower Bound) Value -> 5.00
• For bullish outside line segment, choose Zen -> Outside Stroke/Line Segment -> Inside Channel -> (Upper Bound) Value -> -15.00 -> (Lower Bound) Value -> -25.00
• For bearish outside line segment, choose Zen -> Outside Stroke/Line Segment -> Inside Channel -> (Upper Bound) Value -> 25.00 -> (Lower Bound) Value -> 15.00

• For 1st percentile volume spikes, choose Zen -> Volume Spike -> Inside Channel -> (Upper Bound) Value -> 25.00 -> (Lower Bound) Value -> 15.00
• For 2nd percentile volume spikes, choose Zen -> Volume Spike -> Inside Channel -> (Upper Bound) Value -> 15.00 -> (Lower Bound) Value -> 5.00

Minor changes: 1. Added labels to indicate the end of higher level and higher higher level line segments. 2. Improved speed in drawing strokes and line segments.
Note: Alerts set previously may need to be updated or reset.