CS5120
error A script's heatmaps can hold at most max cells: clear old columns (heatmap.clear) or add fewer rows.
#What it means
A script's heatmaps together can hold at most 500,000 non-empty cells. Every column added with hm.column, hm.add or hm.cell counts its non-empty cells (na, 0 and negative values are not stored); the run stops when one more column would pass the budget. The chart paints a heatmap as one image, so the budget is about memory, not drawing speed.
#Typical cause
- Adding a column on every bar of a long chart with many rows each, such as a 2,000-row profile on 5,000 bars.
- Adding the same column again on every bar of a lower timeframe (liq.heat gives an hourly column to every bar inside that hour: add it once).
#How to fix it
Add each column once (remember the time of the last one you added), use fewer rows (a coarser step), keep only the newest columns with hm.clear() and a fresh start, or skip cells you do not need to see. See Heatmaps.
#Example
//@chartscript 1
indicator("Too many cells", { overlay: true })
state hm = heatmap.new()
hm.column(time, low, (high - low) / 2000, array.new_float(2000, 1.0))Fixed
//@chartscript 1
indicator("A column per bar, fewer rows", { overlay: true })
state hm = heatmap.new()
hm.column(time, low, (high - low) / 20, array.new_float(20, 1.0))