Perhaps the biggest challenge of writing, from my perspective, is keeping your head in the right place. It can be easy to get giddy when things go well or downcast when they go badly.
There’s also the writing equivalent of mid-term blues. Halfway through a first draft the initial enthusiasm will have faded but you’ll still be miles away from the light at the end of the tunnel (and the redrafting).
Not unlike gambling, staying cool is the way to go. Keep yourself in check, not unlike being the other person on a see-saw. If you’re in danger of getting cocky/giddy, just remind yourself you’re not JK Rowling (NB this does not work if you are JK Rowling, in which case use JRR Tolkien).
If you’re feeling a bit lost, just take a break, assess where you are, what you need to achieve in the short term, and set about it [if you’ve previously written a book, remind yourself that you’ve been through this before and dealt with it then]. If you’re wracked with self-doubt, remember that every writer has felt that way.
If in doubt, just keep buggering on. Write every day, even if only a little. As the Chinese say: don’t be afraid of walking very slowly. Only be afraid of standing still.