Portfolio Risk Monitor Panels
- Утилиты
-
Norbert Hubert Pajak
My professional career and interests are connected to the financial markets. For over a decade, I have attended almost every trading session.
I create automated trading algorithms (robots, bots), known as Expert Advisors, in MQL4 and MQL5. I can also assist with conversions from Pinescript. - Версия: 1.0
- Активации: 10
Portfolio Risk Monitor is a utility for MetaTrader 5 that measures the risk of all open positions on the account. It counts every position, whatever the magic number, the symbol or the way it was opened: by hand, by another Expert Advisor or from the mobile terminal. For each position, each instrument, each asset class and the whole account it shows how much capital would be lost if the price fell to zero, and how much if the price fell by the historical drawdown from the peak.
Portfolio Risk Monitor does not open, close or modify any orders. It only reads the account and draws two panels on the chart. Panels, journal and alerts are available in English, German, Spanish and Polish.
Two risk scenarios
The tool calculates every open position in two scenarios:
- Scenario A, the price falls to 0. A long position loses its whole value from the open price, a short position gains. The result of an instrument is the sum of its long and short positions.
- Scenario B, the price falls by the drawdown from the peak. The drawdown is the largest historical drop of the instrument from a peak to the following low, plus a 10% reserve, or a drawdown in percent that you set. The history is the longest available of D1, W1 and MN1, or a number of D1 bars that you set. The level of the scenario is the peak minus the drawdown. The peak is the highest of three prices: the historical peak, the current price and the highest entry of a long position. When a position was opened below this level, the drawdown is measured from its entry price.
Every result is shown in the account currency and in percent of the balance or the equity. The tool also shows how much more could be lost from the current price and what equity would remain after the scenario. When the equity would fall to zero, the panel says so in red. Accrued swap can be included in the results. Optionally the Stop Loss of a long position and the Take Profit of a short position stop the price move, so the position is counted as closed at that price.
ACCOUNT RISK panel
The ACCOUNT section shows the balance, the equity, the result of the open positions, the margin and free margin, the margin level and the number of BUY and SELL positions. Below it, each scenario shows the result of the long positions, the result of the short positions, the net total, the further loss from the current price and the equity after the scenario.
The table RISK BY INSTRUMENT CLASS adds up the risk for Forex, Indices, Stocks, Crypto, Commodities, ETF, Bonds, Futures, CFD and Other. The class is taken from the sector of the symbol, from its folder in the Market Watch or from the way the broker calculates the contract.
The table RISK BY INSTRUMENT shows each instrument in three rows: Longs, Shorts and TOTAL. Each row has the number of positions, the lot, the current result, the loss to 0 with the percent of capital, the drawdown in percent, the price level of scenario B and the loss to that level with the percent of capital. A row marked "+min" shows what one more long position with the minimum lot of the broker, opened now at the Ask price, would lose to 0 and to the level of scenario B, together with its spread cost. The ALL rows give the totals of the account. Rows whose loss in scenario B reaches 20% of capital are orange, from 50% they are red.
Tick data
For every instrument with positions the tool finds the tick size and the tick value of 1 lot in the account currency. It takes them from the broker. When the broker gives no value, it uses the profit calculation of the terminal, and after that the contract size multiplied by the tick size and by the exchange rate of the profit currency to the account currency. The exchange rate is searched in all symbols of the broker, also through USD or EUR.
The table TICK DATA at the bottom of the panel shows these values and their source. Values found by the tool are grey and read only. When a value cannot be found, the box is yellow: enter the value from the symbol specification and press Enter. Entered values are kept after a restart of the terminal. At start and when a position on such an instrument appears, an alert explains where to find the value and how to calculate it. A new instrument is added to the table as soon as a position on it is opened and stays there until the tool is removed from the chart.
POSITIONS panel
The POSITIONS panel lists every open position grouped by instrument: ticket, symbol, type, lot, open price, magic number (shown as "manual" for positions opened by hand), current result, result at price 0, price level of scenario B and result at that level.
Both panels can be moved with the mouse, collapsed and scrolled, and keep their position and state after a restart. They are refreshed every few seconds and at once after every change of the positions.
Language
The first input, "EA language (panels, journal, alerts)", selects English, German, Spanish or Polish. The choice changes the panels, the journal and the alerts. The calculations are the same in every language, and set files work in all of them. Input names in the MetaTrader window stay in English.
Quick start
- Attach Portfolio Risk Monitor to any chart. One chart is enough, the tool reads the whole account.
- Choose the language in "EA language (panels, journal, alerts)".
- In "Scenario B: drawdown calculated as" choose "Historical drawdown x 1.1 (10% reserve)" or "Set drawdown in % (input below)" and enter the drawdown in "Scenario B: set drawdown in % from the peak".
- In "% of capital based on" choose Balance or Equity.
- Check the TICK DATA table. If a box is yellow, enter the value from the symbol specification.
- Read the scenarios and the tables. The panels update by themselves when positions change.
Requirements
MetaTrader 5, any account type (hedging or netting), any symbols of the broker. Scenario B uses the daily, weekly and monthly history of each instrument from the server of the broker. For a new instrument this history may take a moment to load, and until then the panel shows the scenario B values as not yet known.
Portfolio Risk Monitor does not trade and does not protect the account. Its results are estimates based on the current prices, exchange rates and history of the broker. Commissions, price gaps and a stop out by the broker are not included, and a future drop can be larger than any historical drawdown. This description is not investment advice.
