- Ea doesn t open a new position on another symbol
- I'm new at this
- Multiple orders problem
-
“Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
How To Ask Questions The Smart Way. 2004
When asking about code -
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code.
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problemWe can't see your broken code.
Fix your broken code.
With the information you've provided — we can only guess. And you haven't provided any useful information for that.
-
“Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
How To Ask Questions The Smart Way. 2004
When asking about code -
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code.
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problemWe can't see your broken code.
Fix your broken code.
With the information you've provided — we can only guess. And you haven't provided any useful information for that.
I see. Thank you for the advice then, I apologize.
Okay, so to put an example of what I mean, let's say I have this code:
if(OrdersTotal()==0){ x=OrderSend("EURUSD",OP_BUYSTOP,0.05,1.08580,300,0,0,NULL,0,0,clrGreen); OrderSelect(x,SELECT_BY_TICKET); z=OrderOpenPrice();} while (OrdersTotal()<7){ vintpips=z+0.002; y=OrderSend("EURUSD",OP_BUYSTOP,0.05,vintpips,300,0,0,NULL,0,0,clrGreen); OrderSelect(y,SELECT_BY_TICKET); z=OrderOpenPrice(); } }
With al the variables well defined and such. If i compile this, it works (on the timeframe I've selected) and it opens seven BUYSTOPS, each one at 20 pips from the previous one. What I want to do is alter this code so each of the operations only appears when the last one has been opened, or in other words, the first time the Ask price equals the variable "z" which is the OrderOpenPrice of the last pending BUYSTOP.
So what I have tried is writing some variables around this:
if(OrdersTotal()==0){ x=OrderSend("EURUSD",OP_BUYSTOP,0.05,1.08580,300,0,0,NULL,0,0,clrGreen); OrderSelect(x,SELECT_BY_TICKET); z=OrderOpenPrice();} while (OrdersTotal()<7){ if (Ask>=z){ vintpips=z+0.002; y=OrderSend("EURUSD",OP_BUYSTOP,0.05,vintpips,300,0,0,NULL,0,0,clrGreen); OrderSelect(y,SELECT_BY_TICKET); z=OrderOpenPrice(); } }}
I first tried with "If(Ask==z)" but when It didn't work I thought maybe the timing between the Ask reaching the desired price and the "while " checking the condition was impossible to match, so I tried with the condition seen above, so the first time the "while" could check, if the "Ask" had already reached the price and surpassed it, it would put the next "BUYSTOP", but it doesn't work. I tried adding a condition in case the error was something like the "while" freezing not knowing what to do if the price had not been reached yet, something silly like "if(Ask<z){number++}" but it has not changed anyhing either. Maybe it is just an issue of semantics, but for what I have searched and tried, the "Ask>z" should not be an issue, as both are floating variables (I think, at least I have been able to operate with both, z being a floating variable).
I hope this is more understandable now, and thanks again for the reply!
- Thehopingnoob: I first tried with "If(Ask==z)"
Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum #2 2013.06.07 -
z=OrderOpenPrice();}
We have no idea what z is, or even if it is static or global. Always post all relevant code.
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problem -
x=OrderSend("EURUSD",OP_BUYSTOP,0.05,1.08580,300,0,0,NULL,0,0,clrGreen);
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014 -
while (OrdersTotal()<7){ if (Ask>=z){
If the if is false you have an infinite loop.
-
Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal (MT4) or PositionsTotal (MT5), directly and/or no Magic number filtering on your OrderSelect / Position select loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum 2013.02.15
PositionClose is not working - MQL5 programming forum 2020.02.21
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles 24 July 2006
Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles Small>1 February 2011
-
Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum #2 2013.06.07 - We have no idea what z is, or even if it is static or global. Always post all relevant code.
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problem -
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014 -
If the if is false you have an infinite loop.
-
Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal (MT4) or PositionsTotal (MT5), directly and/or no Magic number filtering on your OrderSelect / Position select loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum 2013.02.15
PositionClose is not working - MQL5 programming forum 2020.02.21
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles 24 July 2006
Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles Small>1 February 2011

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use