darwinex / dwxconnect

Seamlessly link any Trading Strategy in ANY programming language to Darwinex liquidity via MetaTrader 4 or 5. DWX Connect is your very own, fully customizable Trading API!
BSD 3-Clause "New" or "Revised" License
175 stars 89 forks source link

It places several orders. #27

Closed krhismord closed 1 year ago

krhismord commented 2 years ago

Sometimes when open_order() gets triggered it places several orders at the same time. It also happens in the example.

SaraStemPro commented 2 years ago

Is there any solution for this? I have the same problem. Thank you so much.

elvinex commented 1 year ago

Hi, sorry for the late reply. Could you add more info? I assume it is the python version, right? In combination with MT4 or MT5? I will try to replicate the issue. If you can replicate it, could you copy the log? Thanks!

SaraStemPro commented 1 year ago

Yes, it's the python version.

The code:

p = dwx_client() p.open_order(symbol='EURUSD', order_type='buy', lots=0.01, price=0, stop_loss=1.05300, take_profit=0, magic=0, comment='', expiration=0)

When I run this code, MT4 platform open two orders at the same time. What could be the problem?

Thank you for your answer.

elvinex commented 1 year ago

I could not replicate the exact issue. But I modified the code so that the file communication should have less errors.

  1. Added thread locking so that two threads cannot send commands and write to files at the same time.
  2. Added a command ID. In MT4 it will save the last 1000 IDs and only execute a command if the ID was not found.

I hope this solves the issue. Please download the new version and let me know if there is still an issue.

krhismord commented 1 year ago

You should do the same with mt5 as well. It opens several positions when it shouldn't. It is not as recurrent as the MT4 one, but it would be nice if you lock the threads and make it check the ids.

On Wed, Jan 18, 2023 at 9:47 AM elvinex @.***> wrote:

I could not replicate the exact issue. But I modified the code so that the file communication should have less errors.

  1. Added thread locking so that two threads cannot send commands and write to files at the same time.
  2. Added a command ID. In MT4 it will safe the last 1000 IDs and only execute a command if the ID was not found.

I hope this solves the issue. Please download the new version and let me know if there is still an issue.

— Reply to this email directly, view it on GitHub https://github.com/darwinex/dwxconnect/issues/27#issuecomment-1387101893, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2YSYA75KAM4NDWOLG6WQE3WS7YA5ANCNFSM6AAAAAAR7L6FNI . You are receiving this because you authored the thread.Message ID: @.***>

elvinex commented 1 year ago

Thanks for the info. I updated all code (python, java, dotnet, MT4, MT5). If it happens with the new code, please let me know.