* Indexes turn lower in afternoon trading
* Fall in crude oil weighs on energy shares
* Investors unnerved by Canadian parliament shooting
* Indexes down: Dow 0.45 pct, S&P 500 0.23 pct, Nasdaq 0.29 pct
By Yasmeen Abutaleb
NEW YORK, Oct 22 (Reuters) - U.S. stocks were lower in afternoon trading on Wednesday, with major indexes erasing earlier gains as a shooting at the Canadian parliament unnerved investors and Boeing and Biogen sold off following results.
Indexes had traded in positive territory for much of the session, putting the S&P 500 on track for a fifth straight day of gains. Earnings initially drove the move higher, with technology and material shares up on the back of strong results.
Market benchmarks began drifting lower in late morning after a gunman fatally wounded a soldier in Ottawa, the Canadian capital, and then entered the country's parliament buildings, chased by police. By early afternoon, the market had given up earlier gains.
"If markets can connect the dots that this is a wider-ranging concern on domestic terrorism, it'll put weight on the markets along with global growth," said John Canally, chief economic and investment strategist for LPL Financial.
"If it's unrelated to terrorism, markets can probably move on and focus on fundamentals."
Biogen Idec fell 5 percent to $310.42 after sales of its big-selling new multiple sclerosis drug, Tecfidera, fell short of Wall Street's lofty expectations. It also reported a higher-than-expected quarterly profit and raised its full-year earnings forecast.
Boeing Co lost 4.1 percent to $121.91 despite reporting higher-than-expected earnings and lifting its outlook, as analysts raised concern about the costs of the 787 Dreamliner. Its decline comes after a rise of 5.8 percent over the four previous sessions.
Along with healthcare and industrial names, energy shares were among the day's biggest decliners, off 0.9 percent as crude oil lost 2.4 percent.
On the upside, Yahoo Inc and Broadcom rallied a day after both tech companies reported better-than-expected revenue.
Broadcom shares climbed 6.7 percent to $39.83 while Yahoo was up 5.7 percent at $42.46; the two made up the S&P 500's top percentage gainers.
In the latest economic data, consumer prices rose 0.1 percent in September as energy costs fell broadly, painting a weak inflation picture that could give the Federal Reserve room to keep interest rates low for a while.
At 3:01 p.m. the Dow Jones industrial average fell 75.17 points, or 0.45 percent, to 16,539.64, the S&P 500 lost 4.4 points, or 0.23 percent, to 1,936.88 and the Nasdaq Composite dropped 12.80 points, or 0.29 percent, to 4,406.68.
Declining issues outnumbered advancing ones on the NYSE by 1,851 to 1,183, for a 1.56-to-1 ratio on the downside; on the Nasdaq, 1,800 issues fell and 863 advanced for a 2.09-to-1 ratio favoring decliners.
The benchmark S&P 500 index was posting 44 new 52-week highs and 1 new low; the Nasdaq Composite was recording 53 new highs and 30 new lows. (Editing by Nick Zieminski)