Best advanced flow to charge car at lowest price (mean value during x hours before x o'clock)

I have tried to make some (semi)advanced flows to optimize charging a car when price is low. I have used a card from power by the hour, as to be seen on the attached image. Unfortunately this has an upper limit of 8 hours of the average period. How can i adjust this value? Maybe making my own flowcard, based on this?
Also i want to make a loop, checking each hour if the average of the next 8 hours is the lowest before a fixed time. In this example before 17 o’clock.
I am really not sure if i am moving in the right direction? Or maybe there are other ways to do this much more elegant og efficient? Unfortunately, i have not been able to find any other examples of this in the forum - so hopefully somebody can help me finding a rater optimal way to do this!

Using functions from “Power by the hour” leads to troubles, around 1300, due to the wrong price in the app (at least for Norway). Are there any ways to use for example the app “Strømregning” to setup the same flow / obtain optimized EV-charging?

OK. Now, i found that the app “Heating controller” has much of the same cards as Power by the hour. And “Heating controller” works very fine with values from “Strømregning”. So, this cased is solved. But not the question about looping …