If I have a complicated if-then structure I use EXCEL (LO) to display all options and my wanted results..
I'm trying to capture a state, ( On or Off ) rather than the value ( 1 or 0 ).
ok, ON = 1 and Off = 0, where is the problem?
In mt4 true = 1 and false = 0.
Yellowbeard: Therefore, when X != High, Y = 0. Which is fine. But, in some cases, I need Y to remain as 1 to show that a high has been reached.
- You must come up with a concrete description before you can code it. "Fine" but sometimes not can't be coded.show that a high has been reachedA high is always reached until it is exceeded.
- Don't use 0 and 1 when you mean true and false. Use meaning full variable names. You should be able to read the code out loud and it be good English
bool isXhigh = (X == High); // True if X == High, false if X != High if(isXhigh) ... // "Is X high" is meaningful. if(y == 0) ... // is not.
- Use real variables and real syntax - there are no mind readers here. "if X = High" is bogus, A) Can't assign high to X inside an if (did you mean if X == High?), B) High is an array, can't use an array by itself.
Sorry for the misunderstanding. I assumed that X = High was understood to mean X==High. Fine, is a human term, which is short for " I am fine with the result ". Your code " bool isXhigh = (X == High); // True if X == High, false if X != High " will produce the same problem. Once X != High, X will equal 0. I don't have a lot of faith in using True and False conditions. I have had times when the state was completely ignored. Such as the start of a new period with the statement: if new bar == false. Was completely ignored until I changed it to: if new bar != true. Strange. I need to capture the "1". For example: if Open == High then X =1. I need to store the 1 so that I know that a new high has occurred. Perhaps I'll have to use file write and read statements, in a loop, so that, as a new high is reached, the EA will read the file to see if a "1" is already stored.
Yellowbeard: I don't have a lot of faith in using True and False conditions. | Then you must not "have a lot of faith" that Print(2+2) will output 4 |
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
If I use the statement of : if X = High then Y = 1; each time X = High, Y will be 1. Therefore, when X != High, Y = 0. Which is fine. But, in some cases, I need Y to remain as 1 to show that a high has been reached. Tried a number of approaches, without any luck. Each time X != High, Y = 0. Can someone point me in the right direction as to how I can solve this?
Thanks!