Controlling 3inch gate valve with arduino

Im trying to open and close a gate valve with a 12v motor through arduino which i will use relay modules.
Question is how i can know the full opened position without implementing a code and how i cant stop the motor from working when it is full opened or closed with relays.
Or is there any other way to use instead of relays

Standard solutions to this sort of position detection are either sensors (often some sort of limit switch) or measuring current motor draws.

Based on information provided by one or more of these methods, you control motor driver.

Does your gate valve already have a 12 volt motor to open and close the valve, or have you already built the mechanism to add a motor to the valve? Do you need to control the flow using the valve, or only, ever, fully open or fully closed?

Sometimes it is possible to use the extra current of a stalled motor to detect closed.

Microchip used to have a series of app notes related to stall detection for automotive electric windows.

I need to control the flow but without adding a pressure sensor i was thinking to implement limiter to the code like 90% open or 10% close. But if there is any other way i appreciate it

Actually you need pressure sensors on either side of the valve to determine open or closed or the flow.

Exactly thats what is the motor, its a 12v power window regulator but it have 2 pins only how i can be sure if its fully opened or closed. What i was thinking now is car windows also have relays, when the window goes all the way up how it know that it should stop.
Should i check for something like2x SPDT relays? Or anything else

In ALL the vehicles I have owned with power windows, the OPERATOR is the one to control the motor. The motors can run on in stalled state for a long time without problems. So your design right now has problems.
But, can your motor actually operate the gate valve. I have several 2 inch gate valves and some times they are pretty difficult to completely close.

@soukri, do not cross-post.