How do I get in the will of god. I was told that when things go your way, you are
in the will of God and when nothing is working, you are out of the will of God. How
Do I stay in the will of God or is it just the way things work out?
I don't know who told you that when "everything is going your way" then you are "in the will of God" and that when things go wrong, your out of His will, but this is certainly a secular view of the things of God and in my opinion is certainly not Biblical.
First, no one can know if what is happening in your life is due to the result of our own decisions, or part of God's plan. That is between you and Him. It is true however, that He is in control of everything that happens, meaning He allows (not necessarily causes) both good and bad things to happen.
We all struggle with this question of knowing, is what I'm doing, or is what is happening God's will. First, there is a difference between 'doing the will of God' from what is happening in my life, being the the will of God. Doing the will of God is as scriptures tells us is a mind set of obeying His word, His commandments and living a true Christian life. Telling others about the good news of Jesus, helping others, loving one another are just some of the things that God requires us to do;
"Teach me to do your will, for you are my God; may your good Spirit lead me on level ground. For your name's sake, O LORD, preserve my life; in your righteousness, bring me out of trouble." Ps. 143:10-11
Now again, if your referring to if what is happening in your life being His will for you, the reality is, what ever He wants you to do, it will be done. There is nothing you can do to change or affect that. Don't worry about the details of an issue being His will. Take your concerns to Him, He will guide your way. If the end results are less-than desirable, then God had a reason for that outcome, maybe to teach you something, maybe He knows in the end it will not be right for you etc. But as I said, no one can tell you that what is happening is, or is not the 'will of God'. Pray, ask for help, ask for guidance and keep the details to Him. He won't let you down.