In a recent study, Lin proposed the LCS for short-term stock forecast. Gershoff proposed the extended Classifier system(XCS) agent to model different traders by supplying different input information. Announcement made by Morgan Stanley Capital Investment (MSCI) regarding the additions, removals, and even the weights of the component stocks in its country indices every quarter generally would cause changes to the prices and/or trade volumes of the associated component stocks. This paper takes an XCS in artificial intelligence to dynamically learn and adapt to the changes to the component stocks in order to optimize portfolio allocation of the component stocks. Since these price trends of MSCI component stocks are influenced by unknown and unpredictable surroundings, using XCS to model the fluctuations on financial market allows for the capability to discover the patterns of future trends. This simulation work on the basis of the changes to 121 component stocks in the MSCI Taiwan index between 1998 and 2009 suggests the XCS can produce the great profit and optimize portfolio allocation.