- Why did you post your MT4 question in the Root / MT5 General
section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - True = non-zero, false = zero.
if (OP_BUY==true)
OP_BUY = zero. So you have if(false==true) which is never true.if (OP_SELL==true)
OP_SELL is one. This is if(true==true) which is always true. - You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.
-
!OrderClose(OrderTicket(),LotSize,Bid,3,White);
You can not use any Trade Functions unless you select an order first. - Check your return codes for errors, and report them including GLE/LE
and your variable values. Don't look at GLE/LE
unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles - Sanbach21:No question asked, no reply needed.
William Roeder:
- Why did you post your MT4 question in the Root / MT5 General
section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - True = non-zero, false = zero. OP_BUY = zero. So you have if(false==true) which is never true. OP_SELL is one. This is if(true==true) which is always true.
- You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.
- You can not use any Trade Functions unless you select an order first.
- Check your return codes for errors, and report them including GLE/LE
and your variable values. Don't look at GLE/LE
unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles - No question asked, no reply needed.
Thanks William
In that moment my Keyboard stop to work, sorry
Thanks for your help ,!
William Roeder:
- Why did you post your MT4 question in the Root / MT5 General
section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - True = non-zero, false = zero. OP_BUY = zero. So you have if(false==true) which is never true. OP_SELL is one. This is if(true==true) which is always true.
- You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.
- You can not use any Trade Functions unless you select an order first.
- Check your return codes for errors, and report them including GLE/LE
and your variable values. Don't look at GLE/LE
unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles - No question asked, no reply needed.
Hi William
I Build this Function But it don't works
void closeallopensells() { double MA1= iMA(NULL,0,MA_Fast,0,MODE_EMA,PRICE_CLOSE,0); if (Open[1]> MA1 && Close[1]<MA1) { if( OrderSelect( OrderTicket(), SELECT_BY_POS, MODE_TRADES)) { if( OrderSymbol()== Symbol() && OrderType()== OP_SELL) { while( IsTradeContextBusy()) Sleep( 10); OrderClose( OrderTicket(), OrderLots(), Ask, 10, CLR_NONE); } } } }
Thanks
if( OrderSelect( OrderTicket(), SELECT_BY_POS, MODE_TRADES))
- What part of "You can not use any Trade Functions unless you select an order first." was unclear?
- A ticket is not a position.
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