Compare sensor value from 5 minutes ago to current

Ok so in a binary sensory helper I want to compare the value of loadpower1 from 5 minutes ago to the current value of loadpower1. It doesn’t have to be 5 minutes ago, but a previous value of loadpower1 (less than an hour old). Is there a thing like sensor.history.loadpower1(-5) as in the 5th most recent value for loadpower1 that could be referenced?

Actually just thinking about this some more - I want to use a binary sensor to show on if the delta between current and previous readings is +3000 and off when the delta is -3000.

For discrete values (instead of statistics) you could use a SQL-based query:

Ok I used statistics helper and that gives me the delta