This paper discusses an optimal portfolio selection problem in a continuous-time economy, where the price dynamics of a risky asset are gov-erned by a continuous-time self-exciting threshold model. This model provides a way to describe the effect of regime switching on price dynamics via the self-exciting threshold principle. Its main advantage is to incorporate the regime switching effect without introducing an additional source of uncertainty. A martingale approach is used to discuss the problem. Analytical solutions are derived in some special cases. Numerical examples are given to illustrate the regime-switching effect described by the proposed model.