How It Works
Separate Block Sizes & Pre-Calculations: • Two inputs let you set the TOP block size and the BOTTOM block size independently (default both 5). • The script pre-calculates the highest high over the TOP block and the lowest low over the BOTTOM block using ta.highest and ta.lowest.
Horizontal Line Customization: • Users can toggle each horizontal line on or off (via showTopLine and showBottomLine). • Colors, widths, and line styles (Solid, Dotted, or Dashed) for TOP and BOTTOM lines are customizable with separate inputs. • When a block ends, if the corresponding line is enabled, a horizontal line is drawn using the user‑selected parameters.
Array Storage and Averaging: • The script appends each block’s TOP value to the tops array and each BOTTOM value to the bottoms array, keeping their sizes to a maximum defined by the lookback (default 25). • A helper function, f_avg(), safely computes the average of the array values.
Table Display: • A table is created with three columns: an index column (with fixed labels “Active”, “Prev”, “Prev-2”, “Prev-3”, “Prev-4”, “Avg”), a TOP column, and a BOTTOM column. • The first five rows display the most recent TOP and BOTTOM signals (“Active” being the most recent), and the final row shows the average values.
This code gives you full control over both the TOP and BOTTOM block calculations and the appearance of their horizontal lines, all while presenting the data in an informative table.