Gamestudio Links
Zorro Links
Newest Posts
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, AndrewAMD), 410 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Unable to close MT4 positions from a previous Zorro session. #485640
04/05/22 14:52
04/05/22 14:52
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
I'm currently testing the MT4 bride and during a single Zorro session (i.e. no re-starts) everything runs fine after some minor adjustments to my script.
However, after re-starting both Zorro and MT4 during the weekend, Zorro wasn't able to close trades during market hours from the previous Zorro session.
I'm sure that multiple attempts were made, since I included a printf() function before exitLong() & exitShort().


A couple of points:

- I do receive a 'Error 013: Invalid expression ()' during the beginning of my script (only in TRADEMODE). I've read the manual about this error, but I can't pinpoint the exact cause.
- I also receive messages like '[EUR/USD::L00531] - not found (2123772 lots)' during the beginning. There's no error code included, so I'm not sure what's causing it, since there are no active positions in MT4 with this lot size.
- There's no 075 error message and there are no order-related error messages in the MT4 logs.
- No NFA flag is set.
- I don't run a hedge strategy, but I do run a multi-asset strategy where every asset is assigned to a single strategy.

The manual (MT4 bride) states: "Note that you can not run multiple strategies in parallel on no-hedging or FIFO compliant accounts.", but from what I understand this isn't the case in my setup (or IS it?).

Last edited by Grant; 04/06/22 01:49.
Re: Unable to close MT4 positions from a previous Zorro session. [Re: Grant] #485643
04/06/22 01:58
04/06/22 01:58
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
There's also another issue. When I close Zorro during market hours to provoke / test this situation, all trades are automatically closed. How can this be prevented?

[Linked Image]

Edit: never mind, I saw there was a dialog box and I pressed too fast.

Last edited by Grant; 04/06/22 06:02.
Re: Unable to close MT4 positions from a previous Zorro session. [Re: Grant] #485659
04/10/22 14:43
04/10/22 14:43
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Invalid expression is a hard bug, a script crash due to a wrong expression.

Not found means the trade ending with 00531 was not found in your mt4 trade list and could therefore not be continued. This happens typically when you had closed it manually or when you continue a session with a different account.

Re: Unable to close MT4 positions from a previous Zorro session. [Re: Grant] #485666
04/11/22 10:53
04/11/22 10:53
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Thank you for your explanation, Petra.

Now I see these 'not found' messages are explained in the manual, so I will make some notes!

As for this 013 error message, it isn't causing a crash in my script itself. As stated, it only happens in TRADEMODE during the beginning of a session, right after a data pre-fetch procedure in my script, that runs fine. There's no message in my .log file, but only in Zorro's output window:

[Linked Image]

Maybe this in an internal bug in the MT4 plug-in? I'm using version 4.24.

I will test this as well in a Windows environment. If I can reproduce this error with a sample script, then I can provide it to support when needed.

Last edited by Grant; 04/11/22 11:20.
Re: Unable to close MT4 positions from a previous Zorro session. [Re: Grant] #485669
04/12/22 02:39
04/12/22 02:39
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
I notice that this 013 error doesn't occur in every session. Under Linux/Wine it often does, but not always. So far it doesn't under Windows 10, but that's only one single session so far. I will run more Windows sessions to find out more.

However, the main problem still remains. My script knows the positions, but it's unable to close open positions from a previous session.

Last edited by Grant; 04/12/22 05:06.
Re: Unable to close MT4 positions from a previous Zorro session. [Re: Grant] #485680
04/13/22 12:16
04/13/22 12:16
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
I would fix the 013 bug first because such a bug can have all sorts of bad consequences. It's in your script. If it only happens sometimes then it's dependent on data content, prices or the like.

You can also in your screenshot see a date from 1899, so obvously something is wrong.

https://zorro-project.com/manual/en/trouble.htm

If you cannot find it, we have a script fixing service.

Re: Unable to close MT4 positions from a previous Zorro session. [Re: Grant] #485683
04/13/22 16:34
04/13/22 16:34
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Good point, I missed that wrong date and this might cause this 013 bug.

I'm currently testing my script under Windows and the log shows a normal date range for the LookBack period in TRADEMODE without this 013 error, so the actual cause might be a wrong date handling issue by Wine. It's frustrating, because I prefer Linux over Windows as a future VPS environment.

Quote
Lookback 2000 bars, 2022-04-08..2022-04-12

[990: Fri 22-04-08 16:30] (1.08738)
Start of pre-fetch at Bar #990...
End of pre-fetch.
[991: Fri 22-04-08 16:31] (1.08739)


I don't want to interrupt the live demo test during the week, but I will restart both Zorro and MT4 this weekend to see if it's able to close paper trades next week.

Last edited by Grant; 04/13/22 16:37.
Re: Unable to close MT4 positions from a previous Zorro session. [Re: Grant] #485689
04/13/22 21:09
04/13/22 21:09
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
The reason is probably not Wine. There are still some subtle differences in some Windows date/time functions, but they should have normally no effect in the script.

A 1899 date corresponds to the number 0. So one of your functions under Linux returned 0 instead of a valid date. Maybe it's a missing timestamp in preloaded or downloaded history.

Re: Unable to close MT4 positions from a previous Zorro session. [Re: Grant] #485701
04/15/22 14:02
04/15/22 14:02
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Luckily, you're correct JCL.

This 013 error only occurs on specific dates and only in TRADEMODE with StartDate = NOW. From what I've seen, it only happens during the end of a weekend or right after it. Maybe setting a BarMode can solve this issue? I can't test this right now because there's currenly no 013 error / date 0 issue.

I don't believe it's the cause of my main problem. Even without this error I'm not able to close trades from a previous Zorro/MT4 session.

My trading script does return messages like these during the beginning and there is a recent *.trd file in my Data folder, but active trades remain open after exitLong() / exitShort() attempts.

Quote
[EUR/USD::L01211] - resumed (66 lots)

Last edited by Grant; 04/17/22 08:40.
Re: Unable to close MT4 positions from a previous Zorro session. [Re: Grant] #485722
04/17/22 21:58
04/17/22 21:58
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline OP
Member
Grant  Offline OP
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
I've made a sample script which uses a duplicated *_d.trd version from my trade script to view all active trades.
Just like my trading script, this sample script is unable to close the trades from my previous MT4 session.
There are no error messages at all in the MT4 & Zorro log files. In fact there is no sign from any trading attempts.

output:
Quote

TestCloseAllTrades
Login 0 MT4/5..
!ZorroMT4.dll V4.26
!IG Group Limited connected at UTC 04-17 21:44
Load EUR/USD prices.. 292 h
Load USD/JPY prices.. 292 h
Load GBP/USD prices.. 292 h
Load AUD/USD prices.. 292 h
Load USD/CAD prices.. 292 h
V 2.444 on Sun 22-04-17 23:42:35 ('My Name')

Trade: TestCloseAllTrades 2022-04-17
[USD/CAD::S59229] - resumed (38 lots)
[USD/JPY::L61556] - resumed (1 lots)
[EUR/USD::S67148] - resumed (1 lots)
Assets History\AssetsIG.csv
Lookback 80 bars, 2022-04-12..2022-04-17

[Tue 22-04-12 13:00] 5492 -38.26 0/3 (1.08954)
Asset: EUR/USD | Short open/pending trades: 1
Asset: USD/JPY | Long open/pending trades: 1
Asset: USD/CAD | Short open/pending trades: 1
Logout.. ok


code:
Code
int i;

function run()
	{
	assetList("History\\AssetsIG.csv");
	
	if(is(INITRUN))
		{
		asset("EUR/USD");
		asset("USD/JPY");
		asset("GBP/USD");
		asset("AUD/USD");
		asset("USD/CAD");
		}

	if(Bar > 1)
		{
		while(asset(loop("EUR/USD", "USD/JPY", "GBP/USD", "AUD/USD", "USD/CAD")))	
			{
			i = 0;
			for(current_trades)
				{
				i++;
				if(TradeIsLong)
					{
					printf("\nAsset: %s | Long open/pending trades: %i", Asset, i);	
					exitLong();//Nothing happens
					}
				else
					{
					printf("\nAsset: %s | Short open/pending trades: %i", Asset, i);	
					exitShort();//Nothing happens
					}
				}
			}
		quit();
		}
	}

Page 1 of 3 1 2 3

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1