Nordpool energy prices - trun off if less than three consecutive cheap hours

Hello HA gurus,
Could someone help me on how to create an automation that turns on a switch if there are more than three consecutive hours with cheap energy (below a certain threshold) and turns off if there are less than three hours?
I have a couple of automations in Node-Red that use Guide, but I cannot figure out how to configure it for my use case.