While you could implement a "clever" passive circuit that did what you want as well as possible, it would be at the mercy of device parameter variations AND would depend on what you define as "off" and "on" at the output. Current transfer ratio varies by a factor of 2:1 for the "rank BLL" part and by 8, 3, 3, 4 for the other variants.
As your Vin on/off levels have an 18/4 = 4.5:1 ratio then with a BLL part you could notionally do what you want passively with BLL part - see at end.
Or (better distinction between two voltages) - place two back to back zener diodes in series with opto-LED. eg 2 x 5V6 zeners in opposed series will not pass useful current until Vin ~ >= 7V or so. So for Vin = 4 VAC I ~+ 0 mA.
For Vin = 18 VAC I-n = (18 - 7V - 2V_vopto) / R series.
Input resistance can be controlled with series/parallel input resistance to suit.
simulate this circuit – Schematic created using CircuitLab
- The above is really misusing an optocoupler for something it is not designed for.
Using a comparator or similar circuit which can be designed to switch ar desired voltages allows far greater control.
Using BLL part with CTR = 200% to 400%.
Define on /off boundary = say 12 mA at CTR = 200
So Ioperate = 6 mA at CTR = 400
Adjust Rin so at 18V I in >= 12 mA so >= Vin x 2/3
At CTR = 400 Voperate >= 9V
So at CTR = 200, 4VAC < 12V operate limit
and at CTR = 400, 4 VAC < 6V operate limit.
In practice make voperate slightly under 12V.