VAHEGURU JI KA KHALSA, VAHEGURU JI KI FATEH
In a way, stock trading seems more a business practice than gambling. There is an entire profession - day trading - which involves doing market research to see which stock is worth investing it and whatnot. It is a job that people use to make their livelihoods and involves skill, planning and foresight. Such things are similar to running a business - you need to know what your clients want, have the foresight to update your inventory to match their needs and continuously be alert to the ever-changing desires of your consumers. Granted, there is a risk and chance is involved, but there is risk involved in every profession.
Gambling is an addiction and a disease. It is, for the most part, based on luck (unless you do the counting cards and other methodology considered cheating - you get kicked out of gambling facilities for that). It consumes your life and makes you forget about the world, responsibilities and duties.
But there are those who are addicted to stock trading like gambling as well - impulsive buying and selling. Watching the thrill of making money, followed by the frustration/anger/depression of loss, all in an endless cycle. That would be gambling.
Intent and state of mind may ultimately make the determination.