Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pending Resolution] GET_ALL_OPEN_TRADES_() Bug > 18 trades #59

Open
kkhanh opened this issue Nov 28, 2019 · 6 comments
Open

[Pending Resolution] GET_ALL_OPEN_TRADES_() Bug > 18 trades #59

kkhanh opened this issue Nov 28, 2019 · 6 comments

Comments

@kkhanh
Copy link

kkhanh commented Nov 28, 2019

Hi,

DWX_MTX_GET_ALL_OPEN_TRADES() doesnt return anything when there are more than 18 trades opened.

Any workaround ?

@jorgeromerasan
Copy link

I have the same problem i do not know how to solve!!

Did you find the solution?

Thanks!

@kkhanh
Copy link
Author

kkhanh commented Mar 20, 2020

This is due to a mql string limitation. The return response is too long.

I simply created another DWX_GetOpenOrders function with a new InformPullClient and shrinked the "zmq_ret" response as much as possible. I can successfully pull around 130 opened trades.

@paduel
Copy link
Contributor

paduel commented Apr 1, 2020

I simply created another DWX_GetOpenOrders function with a new InformPullClient and shrinked the "zmq_ret" response as much as possible. I can successfully pull around 130 opened trades.

Could you share the new function that you developed? It would be very useful. Thanks.

@integracore2
Copy link
Collaborator

Great stuff @kkhanh ! 🙂

We'd be super grateful if you could share your solution here? 🙏

It would be benefit the rest of the user community + we would of course patch the code and credit you with the solution!

Many thanks.

@integracore2 integracore2 changed the title GET_ALL_OPEN_TRADES_() Bug > 18 trades [RESOLVED] GET_ALL_OPEN_TRADES_() Bug > 18 trades Apr 16, 2020
@integracore2 integracore2 changed the title [RESOLVED] GET_ALL_OPEN_TRADES_() Bug > 18 trades [Pending Resolution] GET_ALL_OPEN_TRADES_() Bug > 18 trades Apr 16, 2020
@paduel
Copy link
Contributor

paduel commented Apr 16, 2020

Finally I did something similar, creating a new function in mql and its counterpart in python to call it. Curiously I also reached the 130 open trades, but for that I had to replace the dictionary by a list, saving the space that the keys take, then when receiving the message python is responsible for displaying the list in a dictionary to maintain compatibility.

But to reach that limit I had to eliminate several fields of information, like magic number, comment, stop loss, take profit,... but only because in our system they are not necessary. So I think it's not an adequate general solution, and it raises the limit a lot, but the limit still exists.

Although I have not implemented it, I consider that a suitable general solution would be to divide the information in several messages, or even a message by trade, but for it a protocol must be established that allows the receiver to check the integrity of the information, that does not lose messages of trades. Perhaps with an initial message detailing the number of messages that follow it, and a defined numbering for each subsequent message.

@kakalos12
Copy link

kakalos12 commented Apr 2, 2022

I have a solution for this. I just paginate the trade collection. Here is the code example :
`
string trades = "[";
int totalTrades = OrdersTotal();
int pages = OrdersTotal() / ITEM_PER_PAGE + 1;

for (int p = 1; p <= pages; p++)
{
	string trades = "[";
	int groupOrderCount = totalTrades - (p - 1) * ITEM_PER_PAGE > ITEM_PER_PAGE ? ITEM_PER_PAGE : totalTrades - (p - 1) * ITEM_PER_PAGE;

	for (int i = 0; i < groupOrderCount; i++)
	{
		int index = (p - 1) * 10 + i;
		if (!OrderSelect(index, SELECT_BY_POS))
		{
			continue;
		}
		trades += StringFormat(TRADE_FORMAT,
							   OrderSymbol(),
							   OrderTicket(),
							   OrderLots(),
							   OrderType(),
							   OrderOpenPrice(),
							   (int)OrderOpenTime(),
							   OrderStopLoss(),
							   OrderTakeProfit(),
							   OrderProfit(),
							   OrderComment());
		if (i < groupOrderCount - 1)
		{
			trades += ",";
		}
	}
	trades += "]";

	PublishMessage(StringFormat(MSG_FORMAT,
								SYNC_TRADE,
								StringFormat(SYNC_TRADE_FORMAT,
											 pages,
											 p,
											 trades)));
}

`

I had to change the mql code and the backend code to make this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants