The market can do only 3 things.
1. Move Up
2. Move Down
3. Move Sideways.
So with respect to knowing what to do:
1. Don't open trades when the market is moving sideways
2. Open trades when the market moves out of the sideways pattern. (Either up or down)
3. Keep an eye on your position to make sure it doesn't retrace (Maybe consider a stop loss), and also for when the next sideways pattern
emerges... when that happens... you can either:
1. Wait for the next movement (up or down breakout) and get out,
or
2. Just exit position when you identify the sideways movement.
Simple but not necessarily easy.
Most traders hold onto their trades too long. (Many wind up consistently losing because of this one tendency).