Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Scripts

Solfeo - the market as a score (candles to MIDI) - script for MetaTrader 5

Views:
56
Published:
solfeo.png (156.78 KB)
Solfeo.mq5 (12.05 KB) view
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance
Solfeo listens to the market instead of reading it. It writes a standard MIDI file (format 1) with one track per symbol, so you can open it in any player, DAW or score editor.
candles as notes
How the score is written
  • Meter: the autocorrelation of absolute returns at lags of 2, 3 and 4 bars picks 2/4, 3/4 or 4/4, written as the time signature. The summary also prints the one-day autocorrelation: the real metronome of the market is the trading day.
  • Pitch: the cumulative move from the first close, in daily-ATR units (1 ATR = 1 tone by default), quantized to the chosen scale: major, natural minor, chromatic, or the black-key pentatonic (default).
  • Accidentals: a note outside the scale keeps its chromatic pitch, a sharp on an up candle and a flat on a down candle.
  • Duration: candle body against the ATR of the bar timeframe, from a 64th note to a whole note; dotted when the wicks add more than half of the body.
  • Rest: a doji. Tie: same pitch and same direction as the previous note. Fermata: a gap in the data (weekend, holiday) doubles the last note before it.
  • Velocity: tick volume against its average.

Inputs
Symbols (comma separated), General MIDI programs per symbol, timeframe, from and to dates, scale, base note, tones per ATR, doji threshold, fermata gap, tempo, file name. Missing symbols are skipped.

Output (MQL5\Files\Solfeo\)
  •  <Name>.mid: the score.
  •  <Name>_base64.txt: the same file in base64, for web pages.
  •  <Name>_summary.txt: meter, and per instrument the notes, rests, ties, dotted notes, sharps, flats and fermatas.

Each track keeps its own timeline (one event per candle), so instruments drift apart in time: a market that moves a lot plays long notes, a quiet one plays fast ones.

Notes
  • Uses only standard MQL5: FileWriteArray for the binary file and CryptEncode(CRYPT_BASE64) for the text copy. No DLLs.
  • It does not trade and it is not a forecast: it is a sonification, a way to hear volatility and trends.
  • Try a crisis week on H1 with the default pentatonic scale, then the same week in minor.

Export candles and indicators data to external csv file Export candles and indicators data to external csv file

Dynamically export customizable historical bar data (OHLC, Tick Volume) and selected technical indicators (RSI, MACD, ATR, ADX, Stochastic, CCI, MFI, Momentum) directly to a clean .csv file with automatic header generation.

Net Currency Exposure and Hedged Margin Simulator Panel Net Currency Exposure and Hedged Margin Simulator Panel

A real-time CCanvas on-chart utility for MetaTrader 5 that calculates net lot exposure per currency across all open positions and simulates the exact margin, Margin Level (%), and Stop-Out buffer impact of a new Buy or Sell order—automatically accounting for your broker's hedged margin rules.

Periodic VWAP Bands Periodic VWAP Bands

Volume-weighted average price that resets every day, week or month, with two pairs of standard-deviation bands, the previous period's final VWAP and a panel showing how far price is from VWAP in price, points and sigma units.

Currency Strength Meter Currency Strength Meter

Shows the relative strength of USD, EUR, GBP, JPY, CHF, CAD, AUD and NZD, plus an optional gold (XAU) line, built from the 28 major pairs, with a strongest-to-weakest ranking panel.