First realize that this circuit cannot create true zero-cross switching since it relies on the voltage at MT2 to fire the gate. The goal is to get it reasonably close to zero.
The value of R4 is a compromise. You want a small value so the gate triggers near zero. This circuit always uses triac quadrants I or III, so the maximum required gate current is 50 mA. It will typically be much less. The maximum voltage at the trigger point with an R4 of 330 ohms will be about 0.05A * 330 = 16 Volts.
If R4 is really small, you risk damaging the triac if the opto doesn't properly zero-cross.
You also need to be sure that the peak and average power dissipated by R4 is within the capability of the resistor.
An R4 value of 330 ohms is reasonable for the line voltage specified. If your voltage is always lower than this, you could reduce the value of R4 some.
To calculate the average power in R4, you need to integrate the little red piece of sine wave in the second picture.
R5 isn't critical, but you want something there so parasitics don't trigger the triac.
The left side of your circuit is a crude current limiter. If you don't need to control the circuit from a wide range of voltages, you don't need that complexity.