Loading…

Basket Builder Panel

Opening a multi-symbol basket by hand means opening each leg separately, with no single view of what the basket as a whole actually costs in margin or risks if it moves against you - and no visibility into whether the "five different trades" are really one bet wearing several tickets because the legs are highly correlated. This panel builds that view before you commit. Each of the five leg rows is a real interactive control: an edit box for the symbol, an edit box for the lot size, and a button that flips between BUY and SELL. Preview reads every filled-in leg and computes combined margin from MODE_MARGINREQUIRED per symbol (never a hardcoded contract size, so it prices correctly across FX, metals and index CFDs sharing one panel), combined dollar risk at InpStopPips from live tick-value data, and the average pairwise Pearson correlation of recent returns across the chosen legs - flagged plainly as low, moderate or good diversification. Execute Basket sends every leg with a valid symbol and lot size as an independent market order, skipping any leg that already has an open position under this panel's magic number rather than doubling it, so pressing Execute again after a partial failure is safe. Failed legs are reported individually rather than left silent. Notes and limitations - Legs are sent as plain market orders with no stop or target attached; InpStopPips only feeds the risk preview figure, it does not become an actual stop loss on the order. - The margin preview reads MODE_MARGINREQUIRED per symbol at current leverage; it is an approximation of what the basket will cost, not a guaranteed pre-trade margin check from the broker's own engine. - Fixed at five legs. A symbol left blank, or with a zero or invalid lot size, is simply skipped. - Correlation is measured over the chart's own period across whatever symbols are entered; a freshly typed symbol not yet in Market Watch needs a moment for its history to load before Preview can use it. - Execute sends legs one at a time with its own retry loop per leg; a broker-side delay or rejection on one leg does not roll back legs already sent.

Expert advisor · MT5 · v1.0 · Free

About Basket Builder Panel

Basket Builder Panel is an expert advisor (trading robot) for MetaTrader 5. It has 10 settings, such as Default lots, Stop pips and Corr lookback. MQL source code included.

Files in the download: BasketBuilderPanel.ex5, BasketBuilderPanel.mq5, BasketBuilderPanel.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Default lots0.10Lot size preloaded into each leg
Stop pips30Stop distance, in pips, used only for the combined-risk preview
Corr lookback100Bars used to measure pairwise return correlation
Magic number20260383Magic number for orders opened by this panel
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per leg before giving up on it
Retry wait ms500Pause between attempts, milliseconds
Corner1Panel corner: 0=top-left 1=top-right 2=bottom-left 3=bottom-right
X offset12Panel offset from the chosen corner, X pixels
Y offset18Panel offset from the chosen corner, Y pixels

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Risk & Lot Size · Multi-Currency · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria