These are good examples of MPT that are transparent and open source.
Fair warning, it is in Python, but you may be able to convert it to your needs.
https://github.com/AssetMatrix500/Portfolio-Optimization_Enhanced/tree/MPT_Enhanced