[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 38
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
It's a little simpler, we'll work inside the start function.
First, we will create a variable in which we will write the direction of the last candle.
int Candle=-1;
If we fill it with a certain value, one of which will indicate that the candle is bullish, another one will indicate that it is bearish. if -1, then it is nothing (it could not be determined or it has no direction close=open).
Value I propose to use by analogy with a trade order 0 - buy, 1 - sell;
further we write:
if(Close[1]>Open[1]) Candle=0; else
if(Close[1]<Open[1] Candle=1;
now we have a direction defined and we can directly use it in OrderSend( string symbol, int cmd, ...the rest of the crap...) function;
if(Candle!=-1) OrderSend( Symbol(),Candle, ...other stuff...);
Or following your analogy:
if(Candle==0) OpenBuy();
if(Candle==1) OpenSell();
This is how I use it from time to time. Look, now the functions look like this:
I'm reading in the log:
So initially from the buy price to the stop there was a difference of 1.3204 - 1.3194 = 0.001 points.
Further 1.3210 - 1.3201 = 0.009 points
And for some reason, in the second case, the stop was closer to the entry price, but there was no error! I thought about it and did not understand it.
I corrected the error later in a different way. There are already conditions in the code:
if(price > Ask) && if(price < Bid) respectively for buying and selling. Or was there another variant? Now we have no more errors. But, nevertheless, I'd like to listen to an opinion from a more experienced programmer.
That's what I wrote about:
The second error is that you do not check where you put the order.
Or maybe so :
And here is the functionThat's closer to the truth. Thank you very much, I will give it a try.
advise if you can dock variables in mql4, i.e. two int variables and they need to be docked, one variable has number 59 and the other 17, I need to get 5917 ?
advise if it is possible to dock variables in mql4, i.e. two int variables and they need to be docked, one variable has number 59 and the other 17, I need to get 5917 ?
HMM. I didn't understand what you mean before I read the whole thing :) What type of data do you want in the output?
As it turns out, the way I see the solution to this situation is this:
1. Convert int 59 and 17 to string type
2. Then we concatenate the data of these strings.
3. we convert them back to int type
Perhaps there are other variants, but I cannot think otherwise at the moment.
advise if you can dock variables in mql4, i.e. two int variables and they need to be docked, one variable has number 59 and the other 17, I need to get 5917 ?
xxx
in php you can dock variables, i.e. $one = 59; $two = 17; $decision = $one.$two; so we don't add two numbers, we "glue" them together to get 5917
mql4 is not a very powerful language, so I have to make do with what I've got...
mql4 is not a very powerful language, so I have to make do with what I have...
I will have to deal with it. I think I may have forgotten such a simple thing, but when I went to the help I did not find it, maybe the developers did not have such a variant in mind or I just need to look for it.
I'll get to the bottom of this. Thank you for at least one answer, I thought I was dumb and did not remember such elementary things, and when I went to the help I have not found, apparently the developers have not provided such an option. or need to look for more, in any case, thanks for the answers.
To be honest, I do not even know why this may be necessary. Apparently the developers didn't think about it either.