Navigate to https://files.minecraftforge.net/ and download forge based on the Minecraft version you'd like to use
Launch the executable
Change the Minecraft directory if needed and press OK
Open Minecraft, click the launch options tab, and enable JVM arguements, change -Xmx1G to -Xmx2G or -Xmx4G to allocate 2 or for gigabytes of RAM respectively.
Click the news tab, select the forge profile and click play
Open Minecraft and close it again, Navigate the .minecraft folder and place the optifine installer in as a mod
Optifine and Forge are now set up and ready for shaders