In some programming languages (most of the ones I've come across, which is only a few), ints can be treated as booleans. For example, the number 1 could either indicate the integer '1', or the boolean value true. 0 could be '0' or false. In the majority of those that allow this awesome feature, any integer other than 0 can be treated as true. Obviously, this works the other way around. In other word, these languages could treat the boolean variable x = true as the integer 1. I'm not quite sure if this is how it works with MQL4 specifically, but I have a strong feeling it is. Knowing that, you should be able to figure out your problem.
I don't want to give you the answer directly, 'cause that's not fun. ;) I'll supply you with some sample statements and the corresponding output to help with my other post.
Alert(5<10); //outputs 1 Alert(5>10); //outputs 0 Alert((5<10)>=1); //outputs 1 Alert((5<10)==1); //outputs 1 Alert((5>10)==0); //outputs 1
Specifically, note the format similarities between the above last 3 statements, and the first half of your OrderSend conditions. Good luck and happy coding.
my advice is to make the statements clear, even if the code gets a few lines longer. thats the first thing beginners should lern. do not try to start coding with chained if() statements.
start with building a very clear program, statement after statement. if after if. so the code gets better readable.
btw: don't like the behavior of mql in this case. bool-int comparison, could be a very hard to find bug. compiler should at least give a warning...
my advice is to make the statements clear, even if the code gets a few lines longer. thats the first thing beginners should lern. do not try to start coding with chained if() statements.
start with building a very clear program, statement after statement. if after if. so the code gets better readable.
btw: don't like the behavior of mql in this case. bool-int comparison, could be a very hard to find bug. compiler should at least give a warning...
Totally agree with you, zzuegg. As written, the code tries to compare a bool with a double. I think it should be...
if((sig_rvi_0-sig_rvi_1)<=RVIopensell && sig_lwma<sig_sma)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
does anyone have any idea how I can better write the condition for OrderSend()?
If the main line from RVI indicator falls down of zero line. Go short.
If the line goes up thrue the zero line. Go long.
i have this:
picture from RVI: red=short, green=long
i can't write:
if((sig_rvi_0>RVIopenbuy)==RVIopenbuy && sig_sma>sig_lwma)
and i have profit, but the signal is not at zero line!
pls help