If you want to trade online first you must have Wi-Fi connection with your DS if you do than good.
Secondly, You have 2 options to trade online.
1. Use the GTS which is located in Jubilife City(DPPT) or Goldenrod City(HGSS)
2. You can sign-up for a forum and exchange your information with other people you want to trade with.