darwinex / dwx-zeromq-connector

Wrapper library for algorithmic trading in Python 3, providing DMA/STP access to Darwinex liquidity via a ZeroMQ-enabled MetaTrader Bridge EA.
https://blog.darwinex.com/zeromq-interface-python-r-metatrader4/
BSD 3-Clause "New" or "Revised" License
342 stars 227 forks source link

The orders sent are opened and closed abruptly #60

Closed ildeb closed 4 years ago

ildeb commented 4 years ago

Hi, when I send a trade order, the SL and TP cannot set or receive the data and remain at zero. After a few seconds MT4 automatically closes the newly opened order but I can't see any error in the logs.

Construct Trade: {'_action': 'OPEN', '_comment': 'DWX', '_type': 1, '_symbol': 'USDCHF', '_price': '0.99868', '_SL': '1.00679', '_TP': '0.98628', '_lots': 0.09, '_magic': 227059, '_ticket': 0}

MT4 Journal:

2019.11.28 23:56:39.598 '30342778': order sell market 0.09 USDCHF sl: 0.00000 tp: 0.00000
2019.11.28 23:56:40.208 '30342778': order was opened : #168755843 sell 0.09 USDCHF at 0.99851 sl: 0.00000 tp: 0.00000
2019.11.28 23:56:40.286 '30342778': close order #168755843 sell 0.09 USDCHF at 0.99851 sl: 0.00000 tp: 0.00000 at price 0.00000
2019.11.28 23:56:40.895 '30342778': order #168755843 sell 0.09 USDCHF at 0.99851 sl: 0.00000 tp: 0.00000 closed at price 0.99861
BobbyJobling commented 4 years ago

Sent from Yahoo Mail on Android

On Thu, 28 Nov 2019 at 23:46, ildebnotifications@github.com wrote:
Hi, when I send a trade order, the SL and TP cannot set or receive the data and remain at zero. After a few seconds MT4 automatically closes the newly opened order but I can't see any error in the logs.

Construct Trade: {'_action': 'OPEN', '_comment': 'DWX', '_type': 1, '_symbol': 'USDCHF', '_price': '0.99868', '_SL': '1.00679', '_TP': '0.98628', '_lots': 0.09, '_magic': 227059, '_ticket': 0}

MT4 Journal: 2019.11.28 23:56:39.598 '30342778': order sell market 0.09 USDCHF sl: 0.00000 tp: 0.00000 2019.11.28 23:56:40.208 '30342778': order was opened : #168755843 sell 0.09 USDCHF at 0.99851 sl: 0.00000 tp: 0.00000 2019.11.28 23:56:40.286 '30342778': close order #168755843 sell 0.09 USDCHF at 0.99851 sl: 0.00000 tp: 0.00000 at price 0.00000 2019.11.28 23:56:40.895 '30342778': order #168755843 sell 0.09 USDCHF at 0.99851 sl: 0.00000 tp: 0.00000 closed at price 0.99861

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

pwerspire commented 4 years ago

Hi,

The SL and TP should be in points, that's why the SL and TP are not valid.

I also wanted to be able to send it like that with values and tried to change the code in the metatrader but I couldn't get it to work

integracore2 commented 4 years ago

Hi @ildeb,

As @pwerspire mentioned, SL and TP values need to be set in points, yes.

This was programmed this way to support any asset class as well as to promote flexibility -> e.g. so traders don't have to necessarily request the latest price first in order to set an appropriate SL/TP.

The MQL Server EA receives the SL/TP values in points and handles the execution accordingly.