As for the capital gain from the future sale of your stock: see this IRS page for the taxation of non-resident aliens:
https://www.irs.gov/businesses/taxation-of-nonresident-aliens-1
If, after you move to India, you have no "effectively connected income," that is, income from performing services or from operating a business in the U.S., then you will not have to file a tax return or pay taxes.
See also: https://www.irs.gov/individuals/international-taxpayers/the-taxation-of-capital-gains-of-nonresident...
"If an alien does not have a tax home in the United States, then the alien’s U.S. source capital gains would be treated as foreign-source and thus nontaxable."
As for your dividends: the US-India treaty has a preferred withholding rate of 25% for dividends. See Table 1 of this IRS Tax Treaties page for the withholding rate:
https://www.irs.gov/individuals/international-taxpayers/tax-treaty-tables