I think you're missing the crux of what @whroeder1 is telling you.
This:
if(variable=1)
means something very different to this:
if(variable==1)
The first means "set variable to 1" (wrong in this context)
The second means "check if variable is 1" (correct in this context).
WHroeder already told you. Read again.
A single "=" is an assignment.
Double "==" is comparison.
if(variable = 1) //<== This does not compare, it assigns 1 to the "variable". // The result is the assigned value. It evaluates to false if you assign zero, true otherwise.
What you want is:
if(variable == 1) // Note the "==" operator
Also, read the documentation: Operations and Expressions
honest_knave:
Thanks a ton all, didn't notice first time I read, super late here/
I think you're missing the crux of what @whroeder1 is telling you.
This:
means something very different to this:
The first means "set variable to 1" (wrong in this context)
The second means "check if variable is 1" (correct in this context).
nadiawicket:
Thanks a ton all, didn't notice first time I read, super late here/
Issue resolved. thanks again
Thanks a ton all, didn't notice first time I read, super late here/
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Why does the variable become stickied to 1 after it is 1 for the first time? It resets to 0 every iteration of the for loop unless there is something to be done if the conditions for variable =1 are met. I would like it to be able to not be 1 when the for loop's subsequent iterations happen. It gets glued to 1; how do I have it reset every iteration?
If we remove the
from the for loop, and then proceed to check out what the variable is with Print(), we can see that it actually does update properly upon every iteration of the for loop. Problem happens when we assign a conditional statement to it upon it being 1.
How do I get variable to not be glued to 1 once I have assigned something to be done upon the conditions for variable 1 are met? I tried reversing it by assigning a conditional statement when it is 0 which did nothing to help. I've got no errors in the tabs.
Heres the EA. Thanks a ton in advanced.