1-3-1 Combo Detection: The script detects the 1-3-1 pattern using the previous 3 candles: Candle 4: Inside Bar (Type 1). Candle 3: Outside Bar (Type 3). Candle 2: Inside Bar (Type 1).
4th Candle Behavior: If the 4th candle (current bar): Stays an inside bar (Type 1) → isFourthInsideBar is true. Becomes a directional bar (Type 2) → isFourthDirectional is true. If either of these conditions is true, the script stops calculating and waits for the next valid 1-3-1 setup.
50% Level Calculation: If the conditions are not met (e.g., the 4th candle doesn’t stop the pattern), the script: Plots a dotted line at the 50% level of the 3rd candle.
Adds a label showing the 50% level. Stop Calculations: No line, box, or label is drawn if the 4th candle is a Type 1 (inside bar) or Type 2 (directional bar).
Visual Outputs: Dotted Box: Marks the 1-3-1 combo setup. 50% Line: Drawn only if the 4th candle does not invalidate the pattern. Label: Displays the 50% level of the 3rd candle.
How to Use: Apply this script on the 12-hour chart.
The script will: Detect valid 1-3-1 patterns. Stop drawing any calculations if the 4th candle is an inside bar (1) or a directional bar (2). Wait for the next valid 1-3-1 combo.