
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
There is a difference between
and what you are doing
in the first if an order fails a value of -1 will be returned, but the bool will interpret this as TRUE
in the second, you are using the condition (Ordersend>0) to assign true or false to the boolean.
There is a difference between
and what you are doing
in the first if an order fails a value of -1 will be returned, but the bool will interpret this as TRUE
in the second, you are using the condition (Ordersend>0) to assign true or false to the boolean.
Is that true? I'm not able to test it out on a demo account (Live trade) now but I did some quick verification on a backtest purposely disrupting OrderSend() with invalid stoploss = ask (Market price) for a long trade. Result is OrderSend() returns a "-1" as expected & my bool var Buy_Ticket returns false as well.
** EDIT **
Did you missed out my conditions "> 0" behind OrderSend()? My original code shows:
Is that true? I'm not able to test it out on a demo account (Live trade) now but I did some quick verification on a backtest purposely disrupting OrderSend() with invalid stoploss = ask (Market price) for a long trade. Result is OrderSend() returns a "-1" as expected & my bool var Buy_Ticket returns false as well.
** EDIT **
Did you missed out my conditions "> 0" behind OrderSend()? My original code shows:
Sorry, yes, I did miss the >0.
I guess that it is just such a strange way to go about it, that I didn't notice it.
@ BigFisherman check the code below
see here
The assignment operator can be used several times in an expression . In this case the processing of the expression is performed from left to right:
y=x=3;
First, the variable x will be assigned the value 3, then the y variable will be assigned the value of x, i.e. also 3.
Sorry, yes, I did miss the >0.
I guess that it is just such a strange way to go about it, that I didn't notice it.
No problem.
I agree it's not a good practice to code it that way; I've coded that part at the early stage of my MQL learning, but since it looked correct to me all this while, I let it be until this duplicate trade problem happens. But apparently, now it "seems like" my original code though confusing appears valid, then it goes back to the original topic of this thread "Duplicate trades.."; this might be a serious & highly unwelcome "rare" bug in mt4, which unfortunately I'm not able to reproduce due to it's rare appearance (1 in over 500+ trades).
For anyone's info, due to how I coded my EA (refer to my 1st post in pg5), SL & TP was only assigned after it detected successful OrderSend() (IMHO is rather foolproof until now). And what happened to my previous duplicate trade was it NEVER made it to set SL & TP for some unknown reason; other than OrderSend() returning "-1" but opened a trade anyway OR "it" opened 2 simultaneous trades in one OrderSend() ** just my own speculation **. Luckily I was right infront of my PC when that happens, so I could just manually close it out; imagine what would happen if I'm away on a holiday.
@ BigFisherman check the code below
Buy_Ticket returns true as expected. What are you trying to say?
i'm not trying to say, i'm saying!
if you use it like this
of course you gonna get true if OrderSend() has been executed
because first is examined whether the result of OrderSend is > 0
and then it's been passed to
but still not the way to handle it right
i'm not trying to say, i'm saying!
if you use it like this
of course you gonna get true if OrderSend() has been executed
because first is examined whether the result of OrderSend is > 0
and then it's been passed to
but still not the way to handle it right
Now I know whose post to filter in mql4, thanks for your input anyway.
y=x=3;
I did try to do that one but MetaEditor always stops me whenever I try to compile.Now I know whose post to filter in mql4,
note: my username in mql5 is the same