In macOS, a handy option called "Show recent applications in Dock" (found in System Settings -> Desktop & Dock) adds a divider to the right-hand side of your Mac's Dock and after it displays any apps you recently used that aren't permanently docked.
By default, this option only shows the three most recently used apps that have since been closed. However, there is a way to make it show more, which can be useful if your workflow involves using a lot of apps consecutively.
If you're comfortable pasting commands into Terminal, it's perfectly possible to increase or decrease the number of recently opened apps that show in your Dock.
Open a Terminal window (the app can be found in /Applications/Utilities/) and paste the following at the command prompt, then press Enter:
defaults write com.apple.dock show-recents -bool true;
defaults write com.apple.dock show-recent-count -int 10;
Note that the -int argument defines the number of recently opened apps that you want to display in the Dock after the divider (10 in this example). You can change the number to suit, and you can revert back to showing three app anytime by using -int 3 in the second command.