Quite right WHRoeder, I was guilty of a quick reply without giving too much thought to the rest of the code.
string sym="EURUSD";
MqlTick tick;
SymbolInfoTick(sym,tick);OrderSend(sym,OP_BUY,1,tick.ask,3,0,0); // Opens a Buy on EURUSD (irrespective of chart symbol)
or
string sym="EURUSD";
OrderSend(sym,OP_BUY,1,SymbolInfoDouble(sym,SYMBOL_ASK),3,0,0); // Opens a Buy on EURUSD (irrespective of chart symbol)
It is getting difficult to me but I'm ok with reverse engineering ;-)
So give me a complete code which open a EURUSD trade but note that ALL CHARTS ARE CLOSED, other parameters could be anything you like..(stop loss, take profit,color etc)
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I have already explained
.
I have already explained
.
Ok thanks
All symbols i need are already exist on market watch, i need to select a specified one to make an order on
As GumRai wrote, you don't "select" a pair before using OrderSend... There is no need to use SymbolSelect()
Or if you want to use a variable:
As GumRai wrote, you don't "select" a pair before using OrderSend... There is no need to use SymbolSelect()
Or if you want to use a variable:
Thanks honest
This fails when the chart is not EURUSD. If you are not trading the current chart's pair, you can not use any predefined Variables - MQL4 Documentation
This fails when the chart is not EURUSD. If you are not trading the current chart's pair, you can not use any predefined Variables - MQL4 Documentation
Quite right WHRoeder, I was guilty of a quick reply without giving too much thought to the rest of the code.
or
Mahmood you need to use marketinfo() to get the price data for a pair differnent to the EA attached chart
https://docs.mql4.com/marketinformation/marketinfo
Mahmood you need to use marketinfo() to get the price data for a pair differnent to the EA attached chart
https://docs.mql4.com/marketinformation/marketinfo
Or SymbolInfoDouble()
Or SymbolInfoTick()
Many ways to skin the proverbial cat. Bear in mind that MarketInfo() is restricted to MQL4, whereas the other methods are also compatible with MQL5.
Mahmood you need to use marketinfo() to get the price data for a pair differnent to the EA attached chart
https://docs.mql4.com/marketinformation/marketinfo