This paper proposes a new simulation-based approach for optimal portfolio allocation in realistic environments with complex dynamics for the state variables and large numbers of factors and assets. A first illustration involves a choice between equity and cash with nonlinear interest rate and market price of risk dynamics. Intertemporal hedging demands significantly increase the demand for stocks and exhibit low volatility. We then analyze settings where stock returns are also predicted by dividend yields and where investors have wealth-dependent relative risk aversion. Large-scale problems with many assets, including the Nasdaq, SP500, bonds, and cash, are also examined.