Problem with EA Filter

 

Hey guys, 

I am fairly new to EA programming and programming in general. My Ea is based on manual strategy that I developed. I tried to connect my if statements with variables, for example if the filter condition is met the filter int gets set to 2 and if the int is 2 than the open position ,,module'' would search for an entrance signal. The obvious problem with that is you can only define variables once. If else statements dont work either because the filter condition should be met until the filter ,,sends''/ detects another signal. The duration is always different and not every candle constelation gives a signal, the signal should not change, a condition check on every new candle does not work because of that too. 

My code is a bit confusion I guess and its not working in that state given the reason stated above. 

Thanks for any tipp or advise regarding my code and sorry for my german english. 

Files:
Reason: