I am sorry, but we cannot write your code for you line by line
By coincidence another post
Close Buy AND Open Sell Before New Tick
Has recently been started referring to a sample EA in the book.
This is obviously the code that you have copied and modified and tried to pass off as your own.
Learning to code takes time and effort, what you are trying to do is too complicated for you.
Start with something simpler and build up your knowledge.
This is my last post in this thread.
thanks GumRai: for your previous helps i appreciate.God bless you.