Open Risk Stacked Area
A single "total open risk" number answers how much could be lost if every stop were hit, but not which position is the biggest contributor, or how that mix built up as positions were opened through the session. This indicator draws up to five coloured bands stacked on top of each other in a subwindow: four named slots, each following one open ticket for as long as it stays open (so its colour does not jump around from tick to tick), plus a fifth grey "Other" band absorbing any position beyond the four tracked slots, so the total stack height always equals true portfolio-wide open risk even with more tickets open than slots. A text legend in the corner lists which symbol/ticket currently occupies each slot. Each position's risk is its stop-loss distance times lot size times tick value, exactly the figure the account would actually lose if that stop were hit - the same calculation this catalogue's Portfolio Heat Thermometer uses, reimplemented locally here since projects in this catalogue never share code by #include. A position with no stop-loss has unmeasurable risk; rather than silently treating it as zero (understating the stack) or guessing, it is excluded from the stack height and counted separately in the legend as "no stop - excluded". Native MQL4 has no DRAW_HISTOGRAM2 (confirmed by a hard compile error), so true stacking is built instead with DRAW_FILLING - which IS present in native MQL4 despite some MQL5-porting notes suggesting the format is unsupported - drawing each band as a fill between a running low and high cumulative level. Notes and limitations - Only four positions get individually coloured, named slots; a busier account will see a fifth "Other" band absorbing the rest - correct for total height, but it does not break down which of the overflow tickets contributes what. - MQL4 keeps no record of which positions were open in the past. The stack only reflects live, current risk, recomputed every tick/timer on the current, still-forming bar. It does NOT reconstruct or show what the stack looked like on bars before the indicator was attached, or on any already-closed historical bar - "how total heat built up" is only observable going forward from attach time, not retroactively. - A slot's ticket assignment is first-come, first-served among currently open positions; it is not ordered by size, open time, or symbol. - Positions with no stop-loss are excluded from the stack height entirely (unmeasurable risk) and only appear as a count in the legend, not a coloured band - this can understate the true worst case if such a position exists, by design (see full description). - Account-wide, not limited to the attached chart's own symbol.
Indicator · MT5 · v1.0 · Free
About Open Risk Stacked Area
Open Risk Stacked Area is an indicator for MetaTrader 5. It has 2 settings, such as Refresh seconds and Show legend panel. MQL source code included.
Files in the download: OpenRiskStackedArea.ex5, OpenRiskStackedArea.mq5, OpenRiskStackedArea.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Refresh seconds | 2 | Legend panel refresh interval |
| Show legend panel | true | Draw a small text legend mapping each colour to its symbol/ticket |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Trading Sessions · MT5 Indicator · MQL5 Source Code