I support the idea. Right decision........!!!
Your code is huge, questions arise often, and it's not good to address you in other people's posts and on other topics.
Great.
Suggestion to the developers: start forming a library of functions. In my opinion, for this, it is desirable to present to the community design requirements (e.g., mandatory description of variables, stipulation of usage limits, number of characters per string, etc.). An MQ article on the subject would be a good idea.
Over time, not only simple but also complex functions will appear in the library.
Will there be published features for real trading?
Yes, they will... Next will be the SetOrder() function for online trading...
Examples of how to use the SetOrder() function:
1. Setting a BuyLimit order with 0.1 lot, 50 pips below the current price:
SetOrder(NULL, OP_BUYLIMIT, 0.1, Ask-50*Point);
2. Setting a BuyStop order with lot 0.3 36 pips above the current price with a 32 pips stop:
SetOrder(NULL, OP_BUYSTOP, 0.3, Ask+36*Point, Ask+(36-32)*Point);
3. Placing a SellLimit order by lot 0.2 at 42 pips above the current price with a 50 pips takeaway:
SetOrder(NULL, OP_SELLLIMIT, 0.2, Bid+42*Point, 0, Bid+(42-50)*Point);
4. Placing a SellStop order by lot 0.5 by 100 pips below the current price with a stop of 30 pips and a takeaway of 70 pips:
SetOrder(NULL, OP_SELLSTOP, 0.5, Bid-100*Point, Bid-(100-30)*Point, Bid-(100+70)*Point);
5. A BuyLimit order with lot 0.1 placed 50 pips below the current price with magic number 123456 and expiry in two hours:
SetOrder(NULL, OP_BUYLIMIT, 0.1, Ask-50*Point, 0, 0, 123456, TimeCurrent()+2*60*60);The trailer is a real-life script with the above examples. The first four examples are commented out.
Hello, Igor!
I support the idea. Right decision........!!!
Your code is huge, questions arise often, and it's not good to address you in other people's posts and on other topics.
Thank you.
Show your version of delays between trades
I do not make any delays between trades. That is, if I need to place two or more orders, I perform these trading operations without a pause between them. But between trade attempts, which have to be repeated if there is an error when contacting the server, I make a pause according to recommendations of MT4 developers. As an example you can see how such pauses are implemented in my SetOrder() function for online trading. Different pauses are made for different errors returned by the trading server.
This function SetOrder() is used for setting pending orders. It is recommended for use in online trading on Demo and Live accounts.
...explain why there is a delay of 7.7,17,11 seconds . Is this a joke or is it justified.
What kind of jokes can there be with real money?
Errors 129 (Incorrect bid or ask price), 130 (Incorrect stops), 134 (Not enough money), 136 (No price) will pause for 7.7 seconds. MT4 developers recommend pauses of more than 5 seconds in these cases. I put 7.7 seconds. Might as well have put 6.1 seconds. I do not like round values because of their attractiveness, so I set non-circular ones.
The 17 second pause was supposed to be for error 145 (Modification prohibited). But since the SetOrder function does not handle modification, I removed the handling of this error. Thank you for bringing this aspect of my function to my attention!
The 11 sec pause is located inside the loop that checks the status of the trade subsystem. You can set it to 15 or 30 seconds. It does not matter what you like.
I also wonder what to do if there is more than one Expert Advisor, and you cannot do without analysis.
For several Expert Advisors in one trading account, the error 146 (trading subsystem is busy) is handled. Function SetOrder waits until the trading subsystem is free.
Warning! I have edited the previous post. Made changes to the SetOrder function.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
In this thread I will post the codes of my functions in MQL4, give examples of their use, and answer questions related to their use. Each function will be published in two posts. The first post will contain the function code, the second - examples of use and short explanations. Sometimes I will attach the code of a script to the second post to actually test the function and display the results.
I will start with functions to handle orders as per Lukyanov's request in the topic "How to Run Two EAs At the Same Time" in the end.
Let the first be the order setting function (MT4 tester version):