Be aware that the indicator (Buyers_Sellers_Profile_Dynamic_SR) is extremely heavy on the CPU due to the 600-bar calculation for the volume profile. Looping through 600 candles on every single tick will definitely cause the platform to freeze and lag. To fix this, the code must be optimized using the 'is_new_bar' logic, so it only calculates the 600 bars once per closed candle rather than on every tick.
Re: Something interesting from Chatgpt/AI please post here
662The source code was requested, but when hassan5041 "asked" for optimization, no one "helped." The source code has now been downloaded 61 times.hassan5041 wrote: Wed Sep 30, 2026 7:02 am Be aware that the indicator (Buyers_Sellers_Profile_Dynamic_SR) is extremely heavy on the CPU due to the 600-bar calculation for the volume profile. Looping through 600 candles on every single tick will definitely cause the platform to freeze and lag. To fix this, the code must be optimized using the 'is_new_bar' logic, so it only calculates the 600 bars once per closed candle rather than on every tick.
###
#### 1. Visual Fidelity & Marker Sizing (1:1 TradingView Match)
* **Concentric Glow Orbs**: Scaled up the layered pivot ring sizes (up to 30pt) to reproduce the rich, glowing, two-tone bullseye orb effect seen in TradingView rather than tiny pixel specks.
* **Crisp Score Badges**: Central score digits inside the markers and right-edge score anchors now use sharp, bold fonts (`Arial Bold`) with high contrast against both dark and light chart themes.
#### 2. Strict Pivot Detection Logic Fix (`ta.pivothigh` / `ta.pivotlow`)
* Corrected the left/right tie-breaking conditions in `IsPivotHigh` and `IsPivotLow` to match Pine Script’s exact built-in behavior (strict left vs. inclusive right). This ensures that historical levels (like high-timeframe structural swing highs/lows) are captured and tracked without false rejections.
#### 3. High CPU Load & Performance Optimization (Smooth 60+ FPS)
* **Smart Redraw Throttling (`InpRedrawMs`)**: On high-tick instruments (e.g., BTCUSD, Gold, EURUSD), MT5 can receive 50–100 ticks per second. Redrawing 150+ graphic objects on every tick was causing high CPU spikes. Added an intelligent redraw rate limiter (default: `200 ms` / 5 FPS for intra-bar updates) while closed bars are still processed **instantly**. This reduces CPU usage by **over 95%** with zero perceptible visual delay.
* **Drawing Object Caching**: Static properties (fill, style, tooltips) are now set only once upon object creation instead of being continuously re-applied on every tick.
* **Profile Math Optimization**: Replaced inner-loop divisions with reciprocal multiplication and fast-skipped zero-volume bars to optimize rolling profile calculations.
#### 4. Dynamic Theme Adaptation
* Added `OnChartEvent` handler (`CHARTEVENT_CHART_CHANGE`) so that transparency blending and colors automatically adapt instantly whenever you change the chart background or color scheme (Dark / Light mode).
---
###
* **Lookback (`profLb`)**: Number of historical bars used by the rolling volume profile (default: `600`).
* **Rows (`profRows`)**: Price row discretization for the profile (default: `72`).
* **Swing Length (`swingLen`)**: Pivot left/right confirmation length (default: `5`).
* **Min Score (`scoreMin`)**: Minimum 0–100 composite score required to activate a level (default: `30.0`).
* **Max Levels (`maxLvl`)**: Maximum concurrent active levels on chart (default: `20`).
* **Redraw Rate Limit (`InpRedrawMs`)**: Minimum milliseconds between intra-bar graphic updates (default: `200` ms, set `0` for raw tick-by-tick).
* **Volume Source (`InpVolSrc`)**: Switch between `Tick Volume` (Forex/CFDs) and `Real Volume` (Exchange-traded stocks/futures/crypto).