Skip to content
All library documents

Optimizing Position Weights Across Five Semiconductor Stocks

Article MQL5 articles

Summary

This article outlines a Python and MQL5 workflow for allocating positions across a basket of five U.S. stocks. It retrieves one-minute price data, converts closes to percentage returns, and examines correlations, distributions, pairwise relationships, and relative volatility. The authors report weak visible correlations, returns centered near zero, and higher volatility in NVIDIA during their sample.

For allocation, the article uses SciPy’s SLSQP optimizer to maximize the geometric mean of portfolio returns, with weights bounded between -1 and 1 and an absolute-weight sum constrained to one. Negative weights represent short exposure. It then translates the optimized weights into an example allocation of ten positions and describes an MQL5 application that monitors positions and closes them at a user-defined profit level. The approach is a demonstration rather than a validated trading system: it optimizes return alone, gives no out-of-sample performance evidence, and does not account for risk, transaction costs, or other practical constraints. The author notes that later work could optimize additional portfolio measures.

Key ideas

  • The workflow uses one-minute returns for five semiconductor-related stocks as inputs to portfolio optimization.
  • The SLSQP objective maximizes geometric mean returns while constraining gross weights to sum to one.
  • Negative optimized weights indicate short positions, while positive weights indicate long positions.
  • The article illustrates converting weights into a target number of positions and implementing position monitoring in MQL5.
  • The example omits risk-adjusted objectives and provides no out-of-sample evidence of profitability.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.