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
there is only one trade context for all EAs. the correct solution is to build your own system of semaphores on global variables.
i have run 4 EAs on 4 minutes. in 10 minutes the error 139 has occurred 7 times
there is only one trade context for all EAs. the correct solution is to build your own semaphore system on global variables.
I have run 4 EAs on 4 min. in 10 min. 7 times error 139
Could you tell me, at least in general terms, what this system of semaphores should be?
1. In particular, how a trade should be made so as not to interfere with others.
2. Slips, checks, timeouts (which were promised to be absent in multithreaded MT, but come on)
And finally. Don't take this as a rebuke. You have a textbook. In it the expert is given. Show me those semaphores there.
Here's my expert. Simple as pants for a ruble twenty. Flip a position every hour. If you really care about traders and profits of brokers (I don't know about people, but I want to get a stable working EA first, and then switch from demo to real), then please, on the example of this EA of mine, show me how I should do it right.
Sincerely,
Quark
P.S. The question of the origin of errors 2, 6, 138 and 4109, which also sometimes appear, remains open.
I have read the English language thread. Yeah... These guys need to learn Russian urgently.
It's not similar, it's the same problem. True, they haven't got errors 2, 6, 138 and 4109 yet. They were only talking about 139.
I don't see the point in IsTradeAllowed, to be honest. Slava himself explained how ten Expert Advisors are allowed to use this function and then suddenly start trading and everybody except the first one gets disappointed.
It would be much better to queue requests where they would pile up, live for some time, and either get executed or deleted. But this is all a dream.
Rather, we would have to create a global variable nTrading, for example, and store there the Expert Advisor's name. And what should other EAs do? Go back to MT3 with its pending orders Or there are other ideas?
By the way, we can do without global variable, something like
where Buy() and Sell() return OP_BUY / OP_SELL on failure and -1 on success.
The disadvantages are obvious - the broker will receive ten orders to open (close) instead of one. If it is automatic, all is well. If it is a human - it will be offended. Worse, if the automaton and the human act according to different logic. For example, an automaton has no queue (as Slava explained to us, one thread, and the orders compete instead of forming a queue), and a human does. Then the trader starts to trade on the real, and he will not even understand why, because he was assured (me - at the seminar-presentation in Alpari) that there is no difference between demo and real.
The second option - each expert and currency is assigned its own Mn, so that the Expert Advisor + currency combination is unique. Then we write the code in such a way that the EA with IM1 will trade in the first second, with IM7 - in the seventh second, etc. after the bar opens. This will give the system one second to trade.
Question to Slava - is a second enough to avoid the problem?
Disadvantages are obvious, scalpers - pipsers will tell you about them :)
Dear developers (and all-all). Thanks for the clarifications. There are still some unanswered questions in this and previous posts. Waiting for an answer.
Quark
if to make a function to set the value of a global variable provided that this variable has a certain value, so that there is no construct
then it will be 100% reliable
something like
No. Stops are executed on the server.
And about the queue - I had an idea to make an EA that executes orders written in a file. And all other experts just write orders to this file.
But it is not very easy for me ( in the sense of competent implementation )... But it is possible to try. By common effort =))
This is the passage I didn't understand:
if(GlobalVariableGet(SemaphoreName)==0.0)
{
GlobalVariableSet(SemaphoreName,1.0);
bSemaphored=true;
break;
}
Now about the logic of this case. Sorry to pester you, but...
If I understood correctly, we're sitting in a while loop until we manage to set the semaphore. Right? Then we trade, knowing that no one is trading except us. Then we return the semaphore to its original state.
Question: how does while(!IsStopped()) work? ? I thought it was a check for Allow Live Trading.
Question: won't those while and Sleep cause lags in the system?
Question: will Sleep and semaphore be processed correctly in test mode?
Another logical question. Between setting and removing the semaphore we have two (maximum) possibilities to handle orders. First Buy() or Sell() and then, below it, CloseOrder(). Won't these two "activities" compete with each other, though inside the EA, as if there were two Expert Advisors? Or the process is guaranteed to be linear and it will not reach CloseOrder() until Buy() returns?
Thank you in advance.
Quark
No. Stops are handled on the server. and in our case there is competition for the client's expert trading flow
I misspoke. Should OrderSend(OP_BUYSTOP... also surround it with code which sets and removes semaphores? Silly question. Sure, you should.
Reworked the trade functions (connected my library) and attached it to another euram - m15. Meijic, of course, has been changed.
I will let you know how it turned out;)