maybe typecast error
double return_price(int ttype) { //function that returns price double price=0;
paul selvan:
maybe typecast error
worked!! thanks so much lol makes sense
if the specific order is found break from loop
for(int cnt=0;cnt<OrdersTotal();cnt++) { if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderType()==ttype && OrderMagicNumber()!=666 && OrderMagicNumber()!=667) {price=OrderOpenPrice(); break;} }
marth tanaka: Im trying to return the openorder price of the selected trade in my pool (only 1) yet I always get 1. What am I doing wrong?
bool result=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
You don't know whether you selected a trade or not. Check your return codes for errors, and report them including GLE/LE. Don't look at it unless you have an error. Don't just silence the compiler, it is trying to help you. Always use strict. Fixing the warnings will save you hours of debugging.
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
Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.if(OrderType()==ttype && OrderMagicNumber()!=666 && OrderMagicNumber()!=667) price=OrderOpenPrice();
This selects all magic numbers except 666 and 667. If it is zero it is not 666 and not 667.Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect 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
MagicNumber: "Magic" Identifier of the Order - MQL4 Articlesint return_price(int ttype)
Prices are not integers.
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
Im trying to return the openorder price of the selected trade in my pool (only 1) yet I always get 1. What am I doing wrong?