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
can I ask if PositionSelect() checks client side or sever side?
I have a strong feeling that the problem is caused by the delay where server (broker side) is processing the request and not updated the client side that's why PositionSelect() runs again
I do strongly feel that there is no difference when we use cTrade vs MqlTradeRequest way and Sleep function should help delay everything to get our client side gets "updated" before PositionSelect() runs again causing a double entry. Checking from my journal tab, > 2013.12.20 08:35:00 Trades '800****': exchange buy 0.01 EURUSD at market placed for execution in 313 ms <
putting sleep more than 400 should be safe???
What do you think?
"I have a strong feeling that the problem is caused by the delay where server (broker side) is processing the request and not updated the client side that's why PositionSelect() runs again"
I also think that this is the cause for the double entry. In my code it's theoretically impossible to send a new order if the current position size is equal or greater than the max allowed position size, so when the PositionSelect() doesn't receive in time the status of the current position, my EA will send in a new order again.
"putting sleep more than 400 should be safe??? "
The bigger the time interval the better but there is a problem. If you turn your position around, in two steps (LONG to SHORT or SHORT to LONG), this extra time delay can be the cause for a bad execution price, especially during macro economic event.
"I have a strong feeling that the problem is caused by the delay where server (broker side) is processing the request and not updated the client side that's why PositionSelect() runs again"
I also think that this is the cause for the double entry. In my code it's theoretically impossible to send a new order if the current position size is equal or greater than the max allowed position size, so when the PositionSelect() doesn't receive in time the status of the current position, my EA will send in a new order again.
"putting sleep more than 400 should be safe??? "
The bigger the time interval the better but there is a problem. If you turn your position around, in two steps (LONG to SHORT or SHORT to LONG), this extra time delay can be the cause for a bad execution price, especially during macro economic event.
I don't know if broker plays apart here but it seems our broker is the same. Alpari.
I have had 1 more double entry since 03-10-2013. I use both methods for sending my order. See my previous post.
this is what I just implemented. hopefully can slove the problem
this is what I just implemented. hopefully can slove the problem
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 :
I agree with snella_moda that the best explanation is :
I think the problem is the (to slow) execution of the PositionSelect(Symbol()) function. Maybe, the new ticks come in so fast, the EA sends in a new order before it receives a response of the PositionSelect(Symbol()). So the current position size is not calculated properly. In my code, its theoretically impossible to send in a new/double order if the current position size is equal or greater than the max allowed position size, see code.
But it's difficult to check.
I think the best think to do is to ask advice from Metaquotes. I will try that.
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:
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:
correction. There is a double "Position opened in..." and 2 trade has been opened.