
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
The line regarding "each tick" might be why it doesn't happen anymore.
The function is only executed, when a new bar appears. So, most likely, only the first tick of a bar can execute a trade. After the first bar, the code get's a 'return' until new bar appears. Maybe this solved it for me.
I think this piece of code is from the articles:
Of course. I mean "why he could see...". The point here is that there is nothing in your code that can explain why you got this 2 trades.
I think it's very important to found the reason behind this issue, of course it's also important to have a workaround (Sleep ?) until we can understand fully what's happening. So I try to resume the situation :
* When using the method PositionOpen from CTrade class, at least 3 users got at some time, 2 deals in the same direction instead of 1, resulting to a position with a doubled volume relative to what is expected.
I use both methods, for opening new position = "old fashion way", modifying the stoploss = "CTrade class".
* This problem seems occur on the same broker, with a symbol where Depth of Market is activated (can the concerned people confirm this please).
Yes the server of broker X, Depth of Market is activated.
* This problem occurs with synchronous order, asynchronous order wasn't used (please confirm).
Yes, asynchronous order wasn't used.
* The problem occurs randomly.
Yes, but only during busy market hours (macro economic events).
In my opinion this problem can easily be solved.
The EA should always wait for a response/answer if the "PositionSelect(Symbol())" function is used and the terminal has updated the data of the function, before it can resume with the execution of the code.
The EA should always wait for a response/answer if the "OrderSend(mrequest,mresult)" function is used and the terminal has updated the data of the function, before it can resume with the execution of the code.
I also mention the terminal itself because the data of the function will be copied to the terminal and this will also take some time.
This way the current position size will always be calculated correctly, so the double order will not take place anymore.
What do you think?
In my opinion this problem can easily be solved.
The EA should always wait for a response/answer if the "PositionSelect(Symbol())" function is used and the terminal has updated the data of the function, before it can resume with the execution of the code.
The EA should always wait for a response/answer if the "OrderSend(mrequest,mresult)" function is used and the terminal has updated the data of the function, before it can resume with the execution of the code.
I also mention the terminal itself because the data of the function will be copied to the terminal and this will also take some time.
This way the current position size will always be calculated correctly, so the double order will not take place anymore.
What do you think?
Not sure what you mean by "always wait for a response..." ?
Anyway I filled a request to ServiceDesk to ask for advice. We will see.
Not sure what you mean by "always wait for a response..." ?
Anyway I filled a request to ServiceDesk to ask for advice. We will see.
"Not sure what you mean by "always wait for a response..." ?"
The EA should wait/stop until the PositionSelect(Symbol()) function has completed copying data about a position into the program environment.
See it as a forced sleep() function.
"Not sure what you mean by "always wait for a response..." ?"
The EA should wait/stop until the PositionSelect(Symbol()) function has completed copying data about a position into the program environment.
See it as a forced sleep() function.