'SQL Desired Result - window functions? Postgresql

I'm in need of adding an additional column onto the below result set. I have columns 1 and 2. Column 3 is the field I would like to create using sql (Postgres). I'm familiar with how to use python to loop through the records one at a time to apply some conditional. However, I'm wondering if there is a way to accomplish this in SQL. I've worked some with window functions. Can't find something to partition by effectively, or can't see how to filter. Was thinking I could go back a few records using "rows preceding and current row" pulling a max, to no avail. Has anyone been able to do this? Essentially, the new field will switch from 1 to 0 based on the 1 or -1. If it switches to 1 based on the 1 from the value column, it will stay 1 until it comes across a -1. Then it will stay 0, until it comes to a 1 in the value. Essentially a buy sell signal.

dataset:

Date Value Trying to get this?
2/7/2022 0 0
2/8/2022 1 1
2/13/2022 0 1
2/14/2022 1 1
2/15/2022 0 1
2/19/2022 0 1
2/20/2022 -1 0
2/21/2022 0 0
2/23/2022 -1 0
2/24/2022 0 0
2/25/2022 1 1
2/26/2022 0 1
2/27/2022 0 1
2/28/2022 1 1
3/1/2022 0 1
3/2/2022 -1 0
3/3/2022 0 0
3/4/2022 0 0
3/5/2022 0 0
3/6/2022 1 1
3/7/2022 0 1
3/13/2022 0 1
3/14/2022 0 1
3/15/2022 -1 0
3/16/2022 -1 0


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source