Loading…

Long Short Basket Equity Line

A basket or pairs trade is judged on relative performance, not on whether the market went up or down that day. Watching two separate baskets of instruments side by side and mentally subtracting one from the other is error-prone and does not scale past a handful of symbols. The naive fix - plotting each basket's raw price - does not work either, since the symbols in a basket are rarely on the same price scale. This indicator rebases every symbol in both the long and short basket to 0% at InpStartBar, averages each basket's percentage performance independently, and plots long-average minus short-average as one spread line. A rising line means the long basket is out-performing the short basket since the rebase point; a falling line means the reverse - this holds regardless of whether the overall market moved up or down, which is the entire point of a basket spread. Symbols with insufficient history from the rebase point are excluded from that basket's average for the bars where they lack data, rather than silently reading as 0% and dragging the basket average toward a false flat reading. Notes and limitations The spread is an average of simple percentage changes per basket, not a capital-weighted or lot-weighted basket - every symbol in a basket counts equally regardless of its typical volatility or a trader's intended position size. Symbols that are misspelled or genuinely unavailable from the broker are logged once to the Experts tab at load and excluded from that basket's average wherever their history is missing; a fully empty basket (all symbols unavailable) causes the indicator to refuse to load. History depth for the plotted line is capped on first calculation (1000 bars) to bound recomputation cost.

Indicator · MT4 · v1.0 · Free

About Long Short Basket Equity Line

Long Short Basket Equity Line is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Long basket, Short basket and Timeframe. MQL source code included.

Files in the download: LongShortBasketLine.ex4, LongShortBasketLine.mq4, LongShortBasketLine.txt.

Settings

SettingDefaultWhat it does
Long basketEURUSD,GBPUSD,AUDUSDComma-separated long basket symbols (broker names, no spaces)
Short basketUSDJPY,USDCHF,USDCADComma-separated short basket symbols (broker names, no spaces)
TimeframePERIOD_H1Timeframe the basket performance is measured on
Start bar200Bar shift used as the zero-rebase anchor (0% at this bar)
Alert on new highfalseAlert once when the spread makes a new high since InpStartBar

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Alerts · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria