Hello,
I've found here in the forum, a script for buy / sell orders with a magic number. The script I've attached. How should the script for when I would like to give the currency specified as a parameter in the Order? I trade with many different currency pairs and do not want to open a chart every time - but for each currency pair I will use a keyboard shortcut for the script.
I hope the translator was correct. :-)
Add a string extern for the Symbol, use this extern instead of Symbol() in the order send and use . . .
MarketInfo(SymbolString, MODE_BID) // instead of Bid // and MarketInfo(SymbolString, MODE_ASK) // instead of Ask
Please bear in mind that script will NOT work with an ECN type broker . . . .
Hello,
I read some posts. I understand that ECN broker don´t accept SL/TP in set order function. I use alpari and there works the script with TP/SL and magic number very good. But your changes don´t wor - better I think I made some mistakes. Can you take a look on the script? Thank you very much.
#property copyright "Copyright © 2010, Khlystov Vladimir" #property link "cmillion@narod.ru" #property show_inputs //-------------------------------------------------------------------- extern int stoploss = 0, takeprofit = 0, Magic = 123456; extern bool SELL = false, BUY = false; extern double Lot = 0.1; extern int slippage = 3; string extern = EURUSD; //-------------------------------------------------------------------- double SL,TP; //-------------------------------------------------------------------- int start() { if (BUY) { if (takeprofit!=0) TP = Ask + takeprofit*Point; else TP=0; if (stoploss!=0) SL = Ask - stoploss*Point; else SL=0; OPENORDER ("Buy"); } if (SELL) { if (takeprofit!=0) TP = Bid - takeprofit*Point; else TP=0; if (stoploss!=0) SL = Bid + stoploss*Point; else SL=0; OPENORDER ("Sell"); } return(0); } //-------------------------------------------------------------------- void OPENORDER(string ord) { int error,err; while (true) { error=true; if (ord=="Buy" ) error=OrderSend(Symbol(),OP_BUY, Lot,MarketInfo(SymbolString, MODE_BID),slippage,SL,TP,"",Magic,3,Blue); if (ord=="Sell") error=OrderSend(Symbol(),OP_SELL,Lot,MarketInfo(SymbolString, MODE_ASK),slippage,SL,TP,"",Magic,3,Red); if (error==-1) { ShowERROR(); err++;Sleep(2000);RefreshRates(); } if (error || err >10) return; } return; } //-------------------------------------------------------------------- void ShowERROR() { int err=GetLastError(); switch ( err ) { case 1: return; default: Alert("Error " ,err," ",Symbol());return; } } //--------------------------------------------------------------------
Compiling 'OpenOrder_ENb-nKopie.mq4'...
.
.
4 error(s), 1 warning(s)
This you could have seen yourself if you did try to compile the code in MetaEditor
string extern ???????????? = EURUSD; // not .... extern string SymbolString = "...........";
You didn't understand what was written in ECN ???
What if Digits ChartSymbol() != SymbolString ???
if (ord=="Buy" ) error=OrderSend(Symbol(),OP_BUY, Lot,MarketInfo(SymbolString, MODE_BID),slippage,SL,TP,"",Magic,3,Blue);Why do you place a ' 3 ' in your OrderSend at that place ??
Your slippage = 3; for a 5 digit account it is often too low.....
I don't think you understand the working of your code
Hi,
first I want say - this is not my code and I´m not a programmer. I don´t know why there is a "3" in the ordersend function.
I receive my signals from private indicators and then I must type my order manually in to MT4. It needs a lot of time so I was looking for a script which can do, what I do manually.
The script must set a market order without a limit. I use for every currency pair an own magic number for helping me later to select my orders. So I found this script in this forum. The only feature that is not included in the ea was that the functional currency pair that can be fixed in the order.
If I need a bigger slippage – OK, then I use a bigger slippage in the script.
But what is the problem with ECN broker? The links in the search function speaks about problems with SL and TP. it does not matter whether is only sent a market order and the sl / tp is set later or whether the sl / tp the same is entered into with the order.
So I´m looking for a script does what I need or I found a programmer who code the script for ne (I pay a fair price then).
Have a nice evening.
Tommy
So I´m looking for a script does what I need or I found a programmer who code the script for ne (I pay a fair price then).
Have a nice evening.
Tommy
Base on your first attachment
Change this :
extern int stoploss = 0, takeprofit = 0, Magic = 123456; extern bool SELL = false, BUY = false; extern double Lot = 0.1; extern int slippage = 3;
into this
extern string symbols = ""; extern int stoploss = 0; extern int takeprofit = 0; extern int Magic = 123456; extern bool SELL = false; extern bool BUY = false; extern double Lot = 0.1; extern int slippage = 3;
Change all the word
Symbols()
into
symbols
change the word
Ask
into
MarketInfo(symbols, MODE_ASK)
change the word
Bid
into
MarketInfo (symbols, MODE_BID)
And test this on demo first will you ?
@ phi.nuts
Thank you very much. Now the script works very good. But I need to confirm each order separately in a window. See screenshot. Can I disable this somehow?
@Raptor UK
Thank you too for the link. That's my 2nd way to solve the problem. I have enough ideas where I need professional help. :-) Now I translate the ideas into english.
Have a nice day.
@ phi.nuts
Thank you very much. Now the script works very good. But I need to confirm each order separately in a window. See screenshot. Can I disable this somehow?
You probably have it set that way in the options . . . untick "Ask manual confirmation"
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I've found here in the forum, a script for buy / sell orders with a magic number. The script I've attached. How should the script for when I would like to give the currency specified as a parameter in the Order? I trade with many different currency pairs and do not want to open a chart every time - but for each currency pair I will use a keyboard shortcut for the script.
I hope the translator was correct. :-)