
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
Thanks for updating the code.
If there is problem in my code, then wont I get the Error:Invalid Price with every order?
I'm using Slippage=3. Is it too high?
Regards
Please search on the forum for "Invalid price error". Then if you can't deal with it, come again to ask.
Hello,
Got more or less the same Solution as you stated earlier.
If the code is ok i.e. Ask for Buying and Bid for Selling and other TP, SL etc. are on safe distance, then I should refreshrates with a pause to get the Actual Bid,Ask rate.
So will put like this and observe if I encounter this problem again or not. Also the Off Quotes one.
Could you please suggest the Shorter form of this for searching:
Any trade gone into even 1 cent of profit will be closed as soon as it's getting zero profit.
Is there any such function which doesn't use the pip distance, rather works on the amount of profit?
Regards
Please search on the forum for "Invalid price error". Then if you can't deal with it, come again to ask.
Hello,
I am trying another thing. That is identifying a range of price. Like I have set Resistance and Support Levels and check whether the price is within this range or not.
So I've written this:
But after compiling getting a warning: Unsafe use of Type 'bool' in operation.
What the compiler is meaning by 'Unsafe' would you please explain a bit?
Regards
if(OpenPrice<=RH && OpenPrice>=RL)
Try splitting the condition.Try splitting the condition.
Hello,
Thanks. No warning is showing now.
By the way, I'm wanting to represent these ranges graphically in the chart like support,resistance lines or rectangular block.
I have been searching for such functions but not getting the right one.
Looked into this but couldn't get the idea of how to do it:
https://docs.mql4.com/objects/objectcreate
Regards
hello please i am having issue with my code
error is:
return value of OrderSelect should be checked
return value of orderdelete should be checked
this is this code below:
void deleteallpendingorders()
{
for(int x=OrdersTotal()-1;x>=0;x--)
{
OrderSelect(x,SELECT_BY_POS,MODE_TRADES);
if((OrderType()==OP_BUY || OrderType()==OP_SELL)==true)
{
orderID = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),900,CLR_NONE); //666
}
else
{
OrderDelete(OrderTicket());
}
if((OrderType()==OP_BUY || OrderType()==OP_SELL)==false)
{
Alert("OrderSelectfalied, returned the error of ",GetLastError());
}
}
}
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
return value of OrderSelect should be checked
return value of orderdelete should be checked
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor
So check them.
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 (MT5/MT4+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
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.